Inventory management in 3.6, part 1 - Showing variables and classes

April 14, 2014

Inventory management in 3.6, part 1 - Showing variables and classes

CFEngine 3.6 introduces a set of features for inventory management, and we’ll have a closer look at one of them today. This feature is part of both the Community and Enterprise editions. It essentially outputs the inventory in terms of classes and variables at a local node. Have a quick look at cf-promises -h of 3.6:

cf-promises -h

Usage: cf-promises [OPTION]… [FILE] Options: –eval-functions, - value - Evaluate functions during syntax checking (may catch more run-time errors). Possible values: ‘yes’, ’no’. Default is ‘yes’ –show-classes, - - Show discovered classes, including those defined in common bundles in policy –show-vars , - - Show discovered variables, including those defined anywhere in policy –help , -h - Print the help message … You might see the two new options –show-classes and –show-vars. Let’s test them out.

cf-promises –show-classes

Class name Meta tags 10_0_2_15 inventory,attribute_name=none,source=agent,hardclass 127_0_0_1 inventory,attribute_name=none,source=agent,hardclass 192_168_33_3 inventory,attribute_name=none,source=agent,hardclass 1_cpu source=agent,derived-from=sys.cpus,hardclass 64_bit source=agent,hardclass April time_based,source=agent,hardclass …. As you probably would expect, this will output all your global classes, together with some meta data about them. A snippet from the corresponding variables option looks like the following.

cf-promises –show-vars

Variable name Variable value Meta tags … default:sys.arch x86_64 inventory,source=agent,attribute_name=Architecture default:sys.bindir /var/cfengine/bin source=agent default:sys.cdate Tue_Apr__8_23_49_37_2014 time_based,source=agent default:sys.cf_agent “/var/cfengine/bin/cf-agent” cfe_internal,source=agent default:sys.cf_execd “/var/cfengine/bin/cf-execd” cfe_internal,source=agent default:sys.cf_key “/var/cfengine/bin/cf-key” cfe_internal,source=agent … The output should be fairly self-explanatory, but note that the variable name here contains the name space before the colon. The main goal of this feature is to make it easier for you to see which inventory you can work with as you develop your policy. In our next blog post, we will look more in depth at the meta tags, as well as enhancements to inventory reporting in CFEngine Enterprise.