Keeping puppet node definitions in CouchDB


If you hadn’t guessed from the previous post I’m a fan of Puppet and mcollective. When trying to automate machine provisioning, having all the nodes defined in a manually edited nodes.pp file doesn’t quite cut it.

Fortunately, puppet allows the use of another program as an external node classifier. With an external node classifier I can use anything to configure my node definitions. For example, CouchDB.

A single node definition in CouchDB might look something like this:

The node classifier script generates yaml that defines a node. It looks like this:

Then, either in Puppet’s nodes.pp, or in individual class files, the definition for each class will appear:

In addition to using the classes for the node, the other information can be used in things like puppet templates for varnish config files.

Previously everything was kept in a text file and now the whole thing is much more complicated. There are more moving parts. So, what advantage has the new approach bought?

I can keep all the node information in a single, highly scalable place (CouchDB) and access it from wherever I want. When a new machine is added to the system it is added as a node to CouchDB and any nodes that need to know about it also have their definitions updated in CouchDB. From that point an mcollective call can tell a puppetmaster to push out node updates.

In other words, complexity has been added but contained, and the overall system operation can be simplified for the general goal of making everything automated.



CoffeeScript in Action


CoffeeScript in Action book cover

I'm the author. Get it from Manning.