The goal is to maintain/detect cfid-$(sys.fqhost) host identity card file.

  • test.cf :
body common control
{
  any::
    bundlesequence  => { test };
    inputs          => {
                          "/var/cfengine/inputs/cfengine_stdlib.cf",
                       };
}

bundle agent test
{

  vars:

    "l"
      slist => readstringlist("/var/cfengine/state/allclasses.txt","#.*","\n","2000","1024k");
    "sublist"
      slist => grep("(?!(Day|Min|Hr|Day|GMT_|Lcycle|Yr|Q\d|Evening|Afternoon|Morning|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday|January|February|March|April|May|June|July|August|September|October|November|December|from_cfexecd)).*","l");
    "tags"
      string => join(", ","sublist");

  files:

    "/tmp/cfid-$(sys.fqhost)"
      create        => "true",
      edit_template => "/tmp/cfid.tmpl";

  reports:

    debug::
      "$(sublist)";

}
  • /tmp/cfid.tmpl :
Title: $(sys.fqhost)
Tags: $(test.tags)

Host $(sys.fqhost)
=======================
  • Action :

$ cf-agent  -f ./test.cf
$ cat /tmp/cfid-blog.nanard.org

Title: blog.nanard.org
Tags: 192_168_1_1, 1_cpu, 32_bit, PK_MD5_1d68579ecaf847e03c7282690b5b9449, am_policy_hub, blog, blog_nanard_org, agent, any, cfengine, cfengine_3, cfengine_3_4, cfengine_3_4_2, org, community_edition, compiled_on_linux_gnu, debian, debian_6, debian_6_0, have_aptitude, i686, ipv4_192, ipv4_192_168, ipv4_192_168_1, ipv4_192_168_1_1, linux, linux_2_6_32_5_686, linux_i686, linux_i686_2_6_32_5_686, linux_i686_2_6_32_5_686__1_SMP_Mon_Feb_25_01_04_36_UTC_2013, mac_00_1e_8c_bf_31_91, net_iface_eth0, nanard_org, architecture_defined, architecture_virtualisation, start_monitor, update_report, virtualisation__sys_tuning_sysctl, xen_independent_wallclock_in_file, service_catalog_sys_tuning_sysctl

Host blog.nanard.org
=======================