Migrating from Puppet to CFEngine

Posted by: admin | in Allgemein @en | 3 years, 7 months ago

Recently, CFEngine added support for datastructures and the ability to parse JSON files. This is big news. Now we can do configuration management on our limited embedded device with the fast CFEngine, without having to relinquish the ease of configuration templates of Puppet. In fact, templates got much, much simpler in CFEngine. See for yourself:

This is our Asterisk extensions.conf template in Puppet:

Versus: the same extensions.conf in CFEngine:

Much simpler, eh?

You don't need that addresses.each do |address| crap. Mustache, the templating engine used in CFEngine, does that automatically for us.

In CFEngine, Manifests are Bundles brought together into so called Promises. Here is the corresponding bundle:

It renders our extensions.conf and restarts the Asterisk service when the file has changed. The bundle gets its data from this JSON file:

All you have to do is a simple template_data => readjson, and you can just access your vars of your JSON in your template directly as you need 'em. Like:

I'm blown away.

And there is more

CFEngine doesn't abort when the JSON file is missing - it just continues with its run through all config files, rendering them without the vars. This makes it very robust and failsafe.

CFEngine ran through all configuration files (and made changes) in under five seconds. In under five seconds - Jesus, this is so unbefuckinglievable. Puppet needed for the same tasks over 50 seconds. And while Puppet consumes about 15 to 30 megs of memory during a run, the CFEngine agent uses below 5 MB.

PS: Restarting a service when a configuration file has changed didn't work until I posted a comment in their issue tracker. And guess what, a benevolent developer sat down and fixed it immediately. Have I already mentioned that the guys at CFEngine are awesome?

Let's crush Puppet.




Allgemein @en 3


RSS / Atom