Setup your devops playground with Puppet, Vagrant & co

Up until now I automated all the management of eXo Forge services using classical shell scripts shared and stored in a SCM (Subversion) .
Even if it is working very well it has various limitations especially in term of maintenance.
Nowadays we can find various server configuration management (CM) tools to ease this maintenance and the management of servers.
I won’t give you a fully detailed guide around these tools as there are already a lot of articles and documentations about them but I will try to give you an overview and a quick startup guide to play with them and to become a good DevOps citizen.
As it is often better and quicker to learn from others I would like to thanks two DevOps Masters that helped and inspired the poor padawan I am : Henri Gomez, Carlos Sanchez and R. Tyler Croy.

Puppet

There are various tools like it (Chef, …) but for now I decided to study Puppet as it is based on conventions and is using a DSL for the configuration.
I know that it may create some limitations (like my dear old friend Apache Maven) when you need to go out of its “standards” but I like this way of thinking…  For now I’m doing some tests and perhaps I’ll come back later to explain how I finally choose Chef (or not).

Resources:

We’ll come later on Puppet itself as you may imagine that we won’t test such tool on a production environnement 🙂
Thus let’s setup a VM dedicated for such tests.
We will use Oracle VirtualBox and some additional tools to do it.

Vagrant

Vagrant is a tool for building and distributing virtualized development environments using Oracle’s VirtualBox.

Resources:

Vagrant is Ruby based, thus you’ll need to install it first. Take care if you are on MacOSX, there is already one version bundled and it’s not always easy to upgrade it. Thus upgrade it only if necessary.
When Ruby is deploy you just install Vagrant with

gem install vagrant

Note : On MacOSX the gem store seems to be in a system area thus you have to launch this command with a sudo

When vagrant is installed you can read its documentation to understand how to create a box ready to be managed with puppet (or chef).
However instead of setting up manually a virtual machine which isn’t reproducible we will use veewee to help us in this task.

Veewee

Veewee is a tool to automate the creation of vagrant base boxes.
It automate the installation of an operating system into a VirtualBox Machine and its configuration to be used by Vagrant (chef and puppet deployment, standards credentials to logon, …).

Resources:

Let’s use Veewee to start and then we’ll see Vagrant on the top of which it adds new features.

  • Veewee is also a ruby gem thus to install it type

    sudo gem install veewee

  • List all existing templates of boxes

    vagrant basebox templates

  • Instantiate a new box definition (exo-ubuntu-server) from a template selected in the list displayed just before (ubuntu-11.04-server-amd64)

    vagrant basebox define 'exo-ubuntu-server' 'ubuntu-11.04-server-amd64'

    • an iso subdirectory must be created in the current directory and the image of the distribution to install have be stored in it if you want to avoid to let Veewee to download it
    • After the creation of the box edit the file definitions/exo-ubuntu-server/postinstall.sh to remove the installation of Chef.
  • Build the box

    vagrant basebox build 'exo-ubuntu-server'

  • Verify the box (In my case I have errors reported for Chef as I removed its support from the VM)

    vagrant basebox validate exo-ubuntu-server

  • Export the vm to a .box file

    vagrant basebox export exo-ubuntu-server

  • Import it into vagrant

    vagrant box add 'exo-ubuntu-server' 'exo-ubuntu-server.box'

  • Initialize it (It will create a Vagrantfile descriptor)

    vagrant init 'exo-ubuntu-server'

  • Start it

    vagrant up

  • Logon into it

    vagrant ssh

We are now ready to play with Puppet on a safe environment that we can recreate when we want/need.

Geppetto

We can edit puppet manifests and modules with a simple text editor but to have auto-completion, and others nice features you may like to use Geppetto (which has the only bad point to be built on top of eclipse – I’m an IntelliJ IDEA addict).

Resources:

Puppet in Action

You now read to follow a tutorial like this one to learn to use puppet and to write manifests for it. Note that the vagrant box we installed already has a server installed and deployed thus don’t do it manually or you’ll have an error.

I hope these few steps may have helped you to start with Puppet, Vagrant and others to give you the opportunity to study more deeply the advantage to deploy them in your own infrastructure.

4 thoughts on “Setup your devops playground with Puppet, Vagrant & co”

    1. Avec plaisir. Je vais essayer d’en faire quelques autres maintenant que j’ai un peu plus d’expĂ©rience avec Puppet.
      On va présenter tout cela lundi soir au Breizh JUG avec Henri Gomez

Comments are closed.