12.16.2010

PFunc

I've had a project over on google code for a while now called PFunc.  It was inspired by FUNC a project I used to use, but due to it's linear processing I figured I could improve by threading.  Func is written in python, and I'm far more comfortable in perl.  So I wrote Pfunc.  It's purpose, like Func's is to execute commands on arbitrary groups of servers immediately.  I figured Pfunc would be a threaded tied-me-over until the Func project progressed and added asynchronous processing of commands.  Instead the Func project has gone in a different direction, trying to be pluggable.  My tied-me-over has lasted much longer than I ever imagined.  I have yet to find something to replace it with.

Pfunc's focus is narrow.  It's about running a command on arbitrary groups of servers instantly all at the same time from the command line and providing easily readable output.  Pfunc also logs the output and exit status of all commands run through it to a mysql database.  Pfunc will copy files, but it is not a configuration manager.  Pfunc should only be used on a closed private network or over an stunnel, because while it does verify commands  to execute and files via DSA signatures, it passes traffic in plain-text. 

Setup is simple, download the code on the central machine you want to control other machines from, and put a copy on all the machines you want to control.  Create a database and import the provided .sql file.  One daemon called dsacertd runs on your central server to provide certs to clients for signing commands and small files.  Configure it to point to your database server and start this up, then create some clients and groups using the phostadd.pl and pgroupadd.pl commands.  Now you can configure the client machines to connect to the same database server and dsacertd server, then start up the pfuncd daemon.  That's it, your done.  Now you can execute arbitrary commands on any group of servers you defined with the pfunc command on your central server.  Add the -o option and get nicely formatted output, or you only receive exit status for each machine in the group.  While pfunc does not suffer from the interpolation problems of Func, command-line interpolation is still an issue.  You've gotta escape what your shell requires escaping.

Pfunc has become an integral part of my workplace and the application I support.  We use it for many things, including our RPM based release process, using it to execute synchronized yum update commands across groups of web servers.

1 comment:

  1. I like pfunc, but after installing and (munging through the config file, I get this...

    bin]# pfunc
    Global symbol "$q" requires explicit package name at Pfunc/HostDB.pm line 273.
    Global symbol "$q" requires explicit package name at Pfunc/HostDB.pm line 274.
    Compilation failed in require at /usr/local/bin/pfunc line 8.
    BEGIN failed--compilation aborted at /usr/local/bin/pfunc line 8.

    Help?

    ReplyDelete