"Fossies" - the Fresh Open Source Software Archive

Member "cfengine-3.15.4/examples/inline-yaml.cf" (7 Jun 2021, 1344 Bytes) of package /linux/misc/cfengine-3.15.4.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #+begin_src cfengine3
    2 bundle agent example_inline_yaml
    3 # @brief Example illustrating inline yaml
    4 {
    5   vars:
    6       # YAML requires "---" header (followed by newline)
    7       # NOTE \n is not interpreted as a newline, instead use $(const.n)
    8 
    9       "yaml_multi_line" data => '---
   10 - "CFEngine Champions":
   11    - Name: "Aleksey Tsalolikhin"
   12      Year: 2011
   13    - Name: "Ted Zlatanov"
   14      Year : 2013';
   15 
   16 
   17       "yaml_single_line" data => '---$(const.n)- key1: value1$(const.n)- key2: value2';
   18 
   19   reports:
   20       "Data container defined from yaml_multi_line: $(with)"
   21         with => storejson( @(yaml_multi_line) );
   22 
   23       "Data container defined from yaml_single_line: $(with)"
   24         with => storejson( @(yaml_single_line) );
   25 }
   26 bundle agent __main__
   27 {
   28   methods:
   29       "example_inline_yaml";
   30 }
   31 #+end_src
   32 ###############################################################################
   33 #+begin_src example_output
   34 #@ ```
   35 #@ R: Data container defined from yaml_multi_line: [
   36 #@   {
   37 #@     "CFEngine Champions": [
   38 #@       {
   39 #@         "Name": "Aleksey Tsalolikhin",
   40 #@         "Year": 2011
   41 #@       },
   42 #@       {
   43 #@         "Name": "Ted Zlatanov",
   44 #@         "Year": 2013
   45 #@       }
   46 #@     ]
   47 #@   }
   48 #@ ]
   49 #@ R: Data container defined from yaml_single_line: [
   50 #@   {
   51 #@     "key1": "value1"
   52 #@   },
   53 #@   {
   54 #@     "key2": "value2"
   55 #@   }
   56 #@ ]
   57 #@ ```
   58 #+end_src