Introducing the Host Info Report for CFEngine Community Edition

Posted by Nick Anderson
April 2, 2014

The Host Info Report has been available in CFEngine Enterprise for some time, it will now be available to community users in CFEngine 3.6. The Host Info Report is a great way to get value immediately if you are using CFEngine for the first time.

So what does it do? The Host Info Report contains detailed information on the host that CFEngine is running on. Read on to learn more about how to enable and use the report.

The host_info_report bundle has been added to the masterfiles policy framework that ships with CFEngine 3.6. This bundle leverages the new mustache template functionality (and serves as a useful example of both mustache templates and the datastate() function) to render a simple plain text summary of host info. The bundle is not activated by default, it can of course be activated automatically by adding host_info_report to the bundlesequence or by a methods type promise. It can be activated on demand by calling the bundle manually using the –bundlesequence or -b options to cf-agent.

Example: console [root@hub ~]# cf-agent -b host_info_report R: Host info report generated and avilable at ‘/var/cfengine/reports/host_info_report.txt’

/var/cfengine/reports/host_info_report.txt:

Host Information

Generated: Mon Mar 31 15:11:46 2014

Identity

Fully Qualified Hostname: hub Host ID: SHA=0cc801bb2b8ed7feb48f698415867314430552c49a24763f65d58e12d446dbac

CFEngine

Version: CFEngine Enterprise 3.6.0b2.630288b Last Agent Run: 2014-03-31 15:11:36 UTC Policy Release ID: d34e3cfe0c1a94ab6ce9bbfbe9b2ad0c47edf6a3 Policy Last Updated: 2014-03-28 21:06:34 UTC

OS

Architecture: x86_64 Os: linux Release: 2.6.32-358.el6.x86_64 Flavor: centos_6 Version: #1 SMP Fri Feb 22 00:31:26 UTC 2013 Uptime: 4186 minutes

Hardware

No. CPUs: 1

Network

Interfaces

  • eth0: IPv4 10.0.2.15
  • eth0: up broadcast running multicast
  • eth1: IPv4 192.168.33.2
  • eth1: up broadcast running multicast
  • lo: IPv4 127.0.0.1
  • lo: up loopback running

IPv4 TCP Ports listening

  • 443
  • 80
  • 27017
  • 5308
  • 25
  • 5432
  • 631
  • 22
  • 6379

This report gives you a high level overview of the individual host including CFEngine, host identity, OS, hardware, and network configuration information. Additional information may be given depending on various classes that are defined. For example currently installed software will be shown if the class show_software is defined. To manually run the report and show the software currently installed simply define show_software using the –define or -D option to cf-agent.

Example: console [root@hub ~]# cf-agent -b host_info_report –define show_software R: Host info report generated and available at ‘/var/cfengine/reports/host_info_report.txt’

/var/cfengine/reports/host_info_report.txt (snipped for brevity): …

IPv4 TCP Ports listening

  • 443
  • 80
  • 27017
  • 5308
  • 25
  • 5432
  • 631
  • 22
  • 6379

Software

[rpm] plymouth-core-libs: version 0.8.3-27.el6.centos, arch x86_64 [rpm] atmel-firmware: version 1.3-7.el6, arch noarch [rpm] libgfortran: version 4.4.7-3.el6, arch x86_64 [rpm] ivtv-firmware: version 20080701-20.2, arch noarch [rpm] gpgme: version 1.1.8-3.el6, arch x86_64 [rpm] centos-indexhtml: version 6-1.el6.centos, arch noarch [rpm] man: version 1.6f-32.el6, arch x86_64 [rpm] diffstat: version 1.51-2.el6, arch x86_64 [rpm] xmlrpc-c-client: version 1.16.24-1209.1840.el6, arch x86_64 [rpm] eject: version 2.1.5-17.el6, arch x86_64

If your interested in looking at the policy that implements the report you can use cf-locate from contrib to quickly find and even display a bundle from your policy.

[root@hub ~]# cf-locate --full host_info_report$ /var/cfengine/masterfiles  -> body or bundle matching 'host_info_report$' found in /var/cfengine/masterfiles/reports/host_info_report.cf:1  bundle agent host_info_report  # @brief Generates a short high level summary of the executing host information  #  # **Example:**  # `cf-agent -b host_info_report`  {    vars:      "host_info_report_template"        handle  => "host_info_report_vars_host_info_report_template",        string  => "$(this.promise_dirname)/../templates/$(this.bundle).mustache",        comment => "Where the report template is found";        "host_info_report_output"        handle  => "host_info_report_vars_host_info_report_output",        string  => "$(sys.workdir)/reports/$(this.bundle).txt",        comment => "Where the host info report should be generated";      methods:      show_software::        "Software"          handle    => "host_info_report_methods_software",          usebundle => host_info_report_software,          comment   => "Collect information about software installed";        any::        "CFEngine"          handle    => "host_info_report_methods_cfengine",          usebundle => host_info_report_cfengine,          comment   => "Collect information about CFEngine";          "Render"          usebundle => host_info_report_render_txt,          comment   => "Render the host info report in plain text";  }

We hope you find this addition to the masterfiles policy framework useful and look forward to your pull requests to add additional information and improve its usefulness.