Cfengine Goodies

To content | To menu | To search

Tuesday 26 March 2013

CFEngine 3 :: Groups definition from csv file

csv_file.pngYou can set groups definition in a csv file. synchronizes csv files and the agent uses them to define contexts.

Example :

Continue reading...

Tuesday 12 March 2013

CFEngine 3 :: Call bundle variable in a csv file


An example to call architecture bundle variable in a csv service file

CFEngine example :

Continue reading...

Tuesday 26 February 2013

CFEngine 3 :: From csv to service_catalog

engine.jpg When you have service catalog datas from #1, we can organize then to feed service with this bundle (first field is the name of the array in accordance with meta service definition constraints):

CFEngine code :

Continue reading...

Friday 15 February 2013

CFEngine 3 :: csv concatenation

If your service catalog datas are stored in csv files and depend on architecture contexts, you can use this concat function.

bundle agent function_meta(prefix,params)


      # variables
      "$(prefix)confidx"       slist   => getindices("$(prefix)_vars.conf");
      "$(prefix)mainfile"      string  => "$(globals.dir_cache)/main/$(prefix)/config.csv";
      "$(prefix)archfile"      string  => "$(globals.dir_cache)/$(architectures_vars.architecture_name)/$(prefix)/config.csv";
      "$(prefix)concatfile"    string  => "$(globals.dir_cache)/main/$(prefix)/concat.csv";
      # readfile
      "$(prefix)len"           int     => readstringarrayidx("$(prefix)meta","$($(prefix)concatfile)","\s*#[^\n]*",";",99,999999);

      "concatlist"    slist   => { "function_meta.$(prefix)mainfile", "function_meta.$(prefix)archfile" };

      "concatlist"    slist   => { "function_meta.$(prefix)mainfile" };


            create      => "true",
            copy_from => u_dcp("$(globals.resources_location)/main/$(prefix)/config.csv");

            create      => "true",
            copy_from   => u_dcp("$(globals.resources_location)/$(architectures_vars.architecture_name)/$(prefix)/config.csv"),
            ifvarclass  => "architecture_defined";

            create        => "true",
            edit_defaults => empty,
            edit_line     => concatWith(@(this.concatlist));


      "$(prefix)::$(this.bundle) csv file :: $(function_meta.$(prefix)concatfile)";

bundle edit_line concatWith(file)


      insert_type    => "file_preserve_block",
      expand_scalars => "false";