Validate server configuration with Serverspec

The other day I had to validate if a bunch of servers was configured according to specification. Now normally I would log in to every server and inspect each detail of the configuration by hand, but in this case that would be too time-consuming. Also, if the configuration would change later I would do the same thing again. And again. You may know the drill.

Suddenly realised that I work in the automation business, I figured I might as well automate this validation process. Why not. After a quick search one tool named Serverspec came to my attention. Serverspec is a Ruby-based (RSpec) command-line tool that validates server configuration for you. You write the server specifications in RSpec files which can get messy, but are at least easier to read than the shell commands you would write as an alternative.

The big pro is that you can run the validation again and again. You can save the server specifications as plain-text files meaning you can manage them in version control easily.

There are a couple of things that were “out of my comfort zone”. Or cons, as you may call them. For example Serverspec is built with validating one server specification per run. Running the tests against multiple servers requires some extra work. Not hard to do, but documentation on this is lacking. Apart from this the documentation is alright!