October 4, 2012

Func Puppet plugin

Although I am not a big fan of Func and especially its syntax, it has proven to be a very useful tool in our infrastructure, especially because of its modularity. It’s dead easy to drop in a new plugin (module) to do your bidding.

I have recently written a Func module to control the Puppet agent. It is able to start / stop / restart the agent and trigger a Puppet run - which I think it is the most useful function of this module. The other functions are also provided by Func’s built-in service module but I think it makes it easier to be able to control all of Puppet agent’s aspects from a single command. The “run” function will trigger a one time apply of the remote configuration no matter if the Puppet agent is running or not.

If you want this module you can get it from Github. To install it, just follow the instructions here.

Basically you have to drop the puppet.py file in /usr/lib/python$version/site-packages/func/minion/modules/ on every box you want this to be available (of course you can use Puppet to achieve this :)). Then restart the Func daemon on all those boxes.

Now, from you Func master you should be able to run:

func "$hostname" call system list_modules

and see “puppet” in the available modules list. To see all available methods for this module:

func "$hostname" call puppet list_methods