In my previous post, Vagrant and Ansible (part1), I wrote about the Vagrant configuration. Let’s now move on to the Ansible part.
Basic Ansible configuration
Ansible needs at least two configuration files, as you can see in the Vagrantfile:
The inventory assigns machine IPs to groups, the playbook configures the hosts or the groups.
I am used to have a complete LAMP stack on my development machine, so that I can test my sites on a browser directly while writing code.
It’s probably an old-school way to develop, but it has worked well until recently.
Now I am working on two projects. One is a completely new project, but it needs to run on a Ubuntu 12.04 server but could be tested without problems on a more recent Linux config; the other is some legacy PHP4 code that runs fine on Ubuntu 12.04 with PHP 5.3 but it’s a mess to adapt to PHP 5.5.
I thus decided to give Vagrant a try and install an Ubuntu 12.04 image on Virtualbox. I found a Vagrantfile on the Internet and, allons-y!, everything works.
Then I thought: what would happen if I misconfigured the Vagrantfile, or the server config, or, worse, deleted the wrong file? Let’s study some devops tools!
Some months ago I read a book on Puppet and did some tests, but I found it quite complicated, and I heard Chef is similar. The new kid on the block is Ansible, and, from what I read on the Internet, it looked nice. Of course I tested it.
And then, keeping a terminal window open on the old VM’s Vagrant directory, it happened: a
vagrant destroy in the wrong directory.
So I had to rush my Ansible study. :)