fiddyspence's blog

Mcollective Config File Hackage

Technical news this week:  I was inspired by a fellow engineer to create a solution to edit config files out of band to the configuration management platform of choice (Puppet) using the orchestration tool of choice (mcollective).

The problem was updating the configuration file for Puppet when Puppet is set to not make any changes during a puppet run - i.e. there a ‘noop = true’ line in the puppet.conf.  Using Puppet to fix this problem is a non-starter.

Thusly did I create 2 mcollective agents - a specific solution to the noop problem (that reports on, enables or disables noop in the puppet.conf) which is called puppetnoop, and another general purpose agent (puppetconf) that can change any setting in any section of the config file.  The implementation is built upon cprice404’s ini_file Puppet Util class which actually updates the configuration file.  Note, that the agent could be extremely easily extended to update programmatically any file that conforms to the ini file format by adding another argument to the agent that indicates which file to edit (by default either agent will check for Puppet[‘config’] which should be the puppet.conf your particular version of Puppet uses.

The only requirement for the agent to work is that the RUBYLIB of the mcollective agent needs to include the cprice404 ini_file utility libraries, which if you’re using Puppet should be auto distributed (on the Ubuntu agent I tested on I had to do some hacking to make sure this was the case).

The code can be found at puppetnoop on github