Review: Learning CFEngine 3

I just finished reading the final release of Diego Zambonis’ Learning CFEngine 3. I can’t recommend this book enough. If your just learning CFEngine 3, if you are versed but not an expert and you like CFEngine you will like this book. If you meet all those criteria and you don’t like the book, I’ll buy you a beer if we ever meet. It’s well worth the 20 dollars, or 14 if you want the ebook (DRM FREE! Thanks OReilly!). Or you can use the discount code AUTHD to get 40% off the print version, and 50% off the e-book version.

The introduction gives an overview of automation, why you would choose CFEngine over or to complement another tool and a brief history of CFEngine. CFEngine has a strong computer science background. It’s nice to know what ideas lead to different design decisions. The introduction gives this background and Diego does a great job of making it a very easy read.

Chapter 2 covers installing CFEngine, bootstraping with an initial configuration , and the obligatory “hello world”. If you have the electronic version of the book (I highly recommend it, but you should probably buy the dead tree version too so you can read the book during air-plane take-off and landing) this is where you will see an outstanding feature.

Coloured syntax highlighting as well as fine little bullet dots that make the very detailed description of the policy easy to reference.  This is a great feature, it makes the policy infinitely easier to read and digest. But just like a late night info-mercial, “Wait, that’s not all folks!”.

Blow up that picture and see near point 3 “In the files:”. Yes that is a hyper-link and it gives you quick access to a cross-referenced index of all the section heading in the CFEngine Reference Manual. All CFEngine keywords in the electronic versions of the book are linked to this index to provide easy access to the official reference documentation about that concept. That is awesome, let me see you do that with the dewy decimal system! (No, I never did learn it. I recall telling my teachers in grade school that I would always have a computer to be able to look that stuff up. Hah, I remember the librarian scoffed and my teacher chuckled) But WAIT! There’s MORE! Yes. Really there is, I’m not kidding.

You can use Diegos’ index as a search provider in your browser. You can use searchplugins.net to create a search for it. Just enter http://cf-learn.info/ref/TEST in the Search URL box. Set the title to “CFEngine Reference Manual”, hit create plug-in and click the link to install the search plug-in. Once that’s done you can create a keyword to use in the address bar as well by clicking your search provider drop-down icon, going to “Manage Search Engines”, selecting the provider and finally “Edit Keyword”. Now you can use the search box in your browser or you can use your keyword in you address bar to quickly and efficiently search the CFEngine Reference Manual. Ok lets get out of chapter two already, I don’t want to completely turn into the shamwow guy.

Chapter 3 covers some more basics including desired-state configuration, promise theory, and convergent configuration which again I think are important to understand why CFEngine works the way it does. The components CFEngine is made of are explained in enough detail to understand the purpose of each, but not so much as to get fatiguing. A high level language structure overview and a section covering other sources of information are also included. I particularly like that early in the book a multitude of resources are laid out. If you get tired of reading the book you already know where to go to take a break and read about the same subject.

Chapter 4 gets down into actually using CFEngine to get things done. There are some good practical examples that are directly useful like configuring sshd configuration parameters and restarting sshd if its config gets changed as well as an example of how to do local user management. More importantly the examples shown in this chapter show techniques that can be used for many different applications. This chapter also covers the use of classes to specify policy that applies to nodes with specific characteristics or conditions. I should mention here that the book mentions that classes will be renamed to contexts so as to not confuse people with the Object-Oriented Programming definition of class which is not the same as CFEngines use of the term. I was able to get this confirmed by Mark Burgess (original author, founder, and Chief Thinking Officer) of CFEngine. I personally am still warming up to this upcoming change, I understand the desire to change it to better communicate the meaning to people who may be more familiar with the OOP use of class and that does fall in line with a core principal of knowledge management but I am still a little sad inside. I always thought the OOP use of the word class was awkward. Anyway, moving on.

Chapter 5 really starts showing more patterns of how to use the declarative policy language to describe intentions and help you “think like CFEngine”. It’s a very good build on Chapter 4 expanding the ideas and getting a little more generic to help you apply the language in different situations. There is a good explanation of Hierarchical Copying much better than others I have read. Also there is pretty good coverage of using arrays for passing configuration to bundles and a very good explanation of how to set default values for bundle parameters. I think this is very important for writing re-usable policy so be sure to read that section twice.

There are two places I think this chapter is slightly lacking. The coverage of arrays doesn’t cover using multi-dimensional arrays and how there are different techniques for dealing with them. I find myself using multi-dimensional arrays frequently when I want to do a similar thing multiple times like define multiple nagios checks and make a single usebundle call. Also I found the section on controlling promise execution order to be a little short. It’s true if you think order matters, you should step back and think if the order really matters or not, and then if you still think order matters, think about it some more. But there are times when order does matter, I tend to find this with variable definitions. I commonly will need to get variables set on the second pass after a class has been defined, and then set another class once that variable has been defined so that I know I can finally run a command. A few practical examples in this section would have been appreciated.

Chapter 6 is about advanced topics. It covers running CFEngine in multiple environments, and unit testing bundles. These are both great and I think there is room for a book to expand on chapters 5 and 6 just about policy writing techniques. Who wants to write that one?

Finally there is an appendix that covers Emacs configuration for editing CFEngine policy files. Well, I don’t have much to say about this section, I am a vim user. I am trying out orgmode but my vim habits are deeply ingrained. If you haven’t used Emacs before and you want to take your brain for a spin go check out Organize Your Life In Plain Text! by Bernt Hansen. He has a pretty amazing orgmode configuration, I barely understand how to use it, let alone much of the configuration. I would have appreciated an appendix B for vim. Neil Watson has a CFEngine 3 syntax highlighting plug-in for vim that I use.

Well, that’s it. So basically I had 3 wants after reading this book, and all centred around more information. I say that’s pretty good. After all you cant please everyone, and I have been known to be highly critical. It really is one of the best technical books I have read in a while. I didn’t find it a dry read at all.

I hope you didn’t make it this far in my diatribe, hopefully you bailed out early on went and bought book and are reading it instead of this. If not, you should head on over to the O’Reilly store and buy a copy. Don’t forget to use the discount code above to save a few bucks.

2 Comments

  • Great review! I went and purchased the ebook right away based on this. With the AUTHD code, it was $7. Looking forward to playing with this soon.

  • Hi Nick,

    Thanks for the review! I am really glad you found the book useful. And thank you as well for the improvement suggestions! I’m starting to build a list for the next release 🙂

    Cheers,
    –Diego

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha