1# This example illustrates the use of inherit_from to inherit body attribute
2# values from another body.
3###############################################################################
4#+begin_src cfengine3
5bundle agent __main__
6{
7  files:
8      "$(this.promise_filename).txt"
9        content => "Hello World$(const.n)2$(const.n)3$(const.n)4$(const.n)half-way
106$(const.n)7$(const.n)8$(const.n)9$(const.n)Byeeeeeee",
11        create => "true";
12
13  reports:
14      "The first 3 lines of this file are:"
15        printfile => head_n( "$(this.promise_filename).txt", "3" );
16
17      "The whole file contains:"
18        printfile => cat( "$(this.promise_filename).txt" );
19}
20
21body printfile head_n(file, lines)
22{
23      # Sets file_to_print the same as cat
24        inherit_from => cat( $(file) );
25
26      # Overrides number_of_lines from cat
27        number_of_lines => "$(lines)";
28}
29body printfile cat(file)
30{
31        file_to_print   => "$(file)";
32        number_of_lines => "inf";
33}
34###############################################################################
35#+begin_src example_output
36#@ ```
37#@ R: The first 3 lines of this file are:
38#@ R: Hello World
39#@ R: 2
40#@ R: 3
41#@ R: The whole file contains:
42#@ R: Hello World
43#@ R: 2
44#@ R: 3
45#@ R: 4
46#@ R: half-way
47#@ R: 6
48#@ R: 7
49#@ R: 8
50#@ R: 9
51#@ R: Byeeeeeee
52#@ ```
53#+end_src
54
55
56