Cfengine: Installing packages with cfengine

From SysadminWiki

cfengine can check the installed versions of packages on a node and install or upgrade them if they are not correct. You need to tell cfengine how to interact with your favourite package manager in the control section and ensure that the packages section is in the action sequence:

control:
        any::
                actionsequence = (
                        packages
                        )

                DefaultPkgMgr = ( rpm )
                RPMcommand = ( /bin/rpm )
                RPMInstallCommand = ( "/usr/bin/yum -y install %s" )


packages:
        any::
                ganglia-gmond action=install

        grid::
                lcg-CA action=install

Then all nodes get ganglia-gmond packages and grid nodes ensure they have the lcg-CA packages.

By default any installed version satisfies cfengine, but checks can be made against a specific version:

packages:
        grid::
                lcg-CA action=install version=1.10

If the version check fails then the package install command is run - so when release 1.11 of lcg-CA is in your local mirror then just change 1.10 to 1.11 in your master cfagent.conf file and all nodes in the grid class will update themselves the next time cfengine runs - simple!

The version of the package is the version reported by the package manager used by cfengine. For example if you have set the package manager to rpm, use

rpm -qi <package>

to know what string it reports as a version. You can set the package manager using pkgmgr variable for each package or defining DefaultPkgMgr variable globally as in the example above. There is a list of valid values for DefaultPkgMgr in the documentation for shortness rpm and dpkg are valid yum and apt-get are not (yet?).

For more information about how to manage packages in cfengine look at the packages section (http://www.cfengine.org/docs/cfengine-Reference.html#packages) of cfengine reference manual.