1#  Copyright 2020 Northern.tech AS
2
3#  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
4
5#  This program is free software; you can redistribute it and/or modify it
6#  under the terms of the GNU General Public License as published by the
7#  Free Software Foundation; version 3.
8
9#  This program is distributed in the hope that it will be useful,
10#  but WITHOUT ANY WARRANTY; without even the implied warranty of
11#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12#  GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
17
18# To the extent this program is licensed as part of the Enterprise
19# versions of Cfengine, the applicable Commercial Open Source License
20# (COSL) may apply to this file if you as a licensee so wish it. See
21# included file COSL.txt.
22
23#+begin_src cfengine3
24body common control
25{
26      bundlesequence => { "test" };
27}
28
29bundle agent test
30{
31  vars:
32      "test" slist => {
33                        1,2,3,
34                        "one", "two", "three",
35                        "long string",
36                        "four", "fix", "six",
37      };
38
39      "test_head9999" slist => sublist("test", "head", 9999);
40      "test_head1" slist => sublist("test", "head", 1);
41      "test_head0" slist => sublist("test", "head", 0);
42
43      "test_tail9999" slist => sublist("test", "tail", 9999);
44      "test_tail10" slist => sublist("test", "tail", 10);
45      "test_tail2" slist => sublist("test", "tail", 2);
46      "test_tail1" slist => sublist("test", "tail", 1);
47      "test_tail0" slist => sublist("test", "tail", 0);
48
49  reports:
50      "The test list is $(test)";
51      "This line should not appear: $(test_head0)";
52      "The head(1) of the test list is $(test_head1)";
53      "The head(9999) of the test list is $(test_head9999)";
54      "This line should not appear: $(test_tail0)";
55      "The tail(1) of the test list is $(test_tail1)";
56      "The tail(10) of the test list is $(test_tail10)";
57      "The tail(2) of the test list is $(test_tail2)";
58      "The tail(9999) of the test list is $(test_tail9999)";
59}
60#+end_src
61###############################################################################
62#+begin_src example_output
63#@ ```
64#@ R: The test list is 1
65#@ R: The test list is 2
66#@ R: The test list is 3
67#@ R: The test list is one
68#@ R: The test list is two
69#@ R: The test list is three
70#@ R: The test list is long string
71#@ R: The test list is four
72#@ R: The test list is fix
73#@ R: The test list is six
74#@ R: The head(1) of the test list is 1
75#@ R: The head(9999) of the test list is 1
76#@ R: The head(9999) of the test list is 2
77#@ R: The head(9999) of the test list is 3
78#@ R: The head(9999) of the test list is one
79#@ R: The head(9999) of the test list is two
80#@ R: The head(9999) of the test list is three
81#@ R: The head(9999) of the test list is long string
82#@ R: The head(9999) of the test list is four
83#@ R: The head(9999) of the test list is fix
84#@ R: The head(9999) of the test list is six
85#@ R: The tail(1) of the test list is six
86#@ R: The tail(10) of the test list is 1
87#@ R: The tail(10) of the test list is 2
88#@ R: The tail(10) of the test list is 3
89#@ R: The tail(10) of the test list is one
90#@ R: The tail(10) of the test list is two
91#@ R: The tail(10) of the test list is three
92#@ R: The tail(10) of the test list is long string
93#@ R: The tail(10) of the test list is four
94#@ R: The tail(10) of the test list is fix
95#@ R: The tail(10) of the test list is six
96#@ R: The tail(2) of the test list is fix
97#@ R: The tail(2) of the test list is six
98#@ R: The tail(9999) of the test list is 1
99#@ R: The tail(9999) of the test list is 2
100#@ R: The tail(9999) of the test list is 3
101#@ R: The tail(9999) of the test list is one
102#@ R: The tail(9999) of the test list is two
103#@ R: The tail(9999) of the test list is three
104#@ R: The tail(9999) of the test list is long string
105#@ R: The tail(9999) of the test list is four
106#@ R: The tail(9999) of the test list is fix
107#@ R: The tail(9999) of the test list is six
108#@ ```
109#+end_src
110