Cfengine Goodies

To content | To menu | To search

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";

Monday 13 February 2012

updates and

question.png Shouldn't the copy go the other way around?

I'm a little confused about the update process for binaries. I'm using the latest svn. It looks like the included will constantly overwrite any updates I install in /usr/local/sbin because of the following:

          comment => "Ensure cfengine binaries were copied to /usr/local/sbin",
           handle => "update_files_usr_local_sbin",
            perms => u_m("755"),
        copy_from => u_cp_nobck("$(sys.workdir)/bin"),
      file_select => u_cf3_files,
     depth_search => u_recurse("1"),
           action => u_immediate;

Shouldn't the copy go the other way around? Everything else seems so well thought out I thought I'd ask here before fixing it.

Overall though, I love the new bootstrap process.

Asked by elwood


Basically it puts a copy of /var/cfengine/bin files to /usr/local/sbin, which is the expected behaviour. A reason behind this is to have all cf-* binaries available in $PATH for the convenience.

One would argue that it would be enough to have a symlinks in /usr/local/sbin pointing back to /var/cfengine/bin. Probably it would, but for the time being it's the full copy.

Answered by Mikhail Gusarov