Using ansible to deploy hosts
I’ve discovered ansible several weeks ago, but only decided to give it a real try the last two.
Test vehicle was the setup of icinga & check_mk on several hosts I wanted to monitor, along with the setup of the master monitoring server.
Some time ago I had already taken a look at deployment software like Chef and Puppet, both being too complicated to set up - or maybe I was not understanding the concepts behind to get the real power !
Test of ansible has proven to be sucessful. I can now simply add some configuration lines to a file and deploy it to 5 hosts , and be sure that all hosts have the same state.
Ansible provides lots of modules, ranging from file transfer and editing, package installation to mysql administration, cron jobs set up. The list of available modules is impressive !
Some years ago I’ve started writing some basic installation scripts that would run automatically and set up a new machine. One of my biggest issues was that modifying lines in config files was not easy to describe - sometimes complex grep/sed/awk constructs were necessary. And in case the script was run again, the file would possibly get edited in a way that is not wanted (either lines twice in the file or lines syntactically incorrect).
Ansible provides the lineinfile module which allows to specify something like “find this line and change it in that way”. If the line does not exist, ansible can create it if desired. If the line exists and is as wanted, ansible will skip the task. Therefore no trouble when running the scripts multiple times.
A nice presentation of ansible (english, nearly 1 hour) was given during RMLL 2013.