Vagrant is a command line interface (CLI) for running and configuring a virtual machine (VM) based off of VirtualBox. It locally creates an isolated environment for developer to mess around and not have to worry about screwing your own local machine.

Problem

I am working on a python/Django blog which I am running on an EC2 machine, while I am developing on Windows 7. My server’s software stack is nginx (proxy http server), WSGI (http server) and PostgreSQL (Database). I am using puppet to ensure that required packages are installed and these services are running all the time.

The most annoying aspect of working with puppet is testing your configuration. In an enterprise environment, there would be a development server on which a developer runs the puppet configuration. It is time consuming to push your local puppet changes to an offsite server just to test your configurations are working, especially if you have to repeat the process 20 times because you misunderstood how puppet works. The nifty solution is to use a local virtual environment.

Solution

I am using the virtual environment for 4 different purposes:

  1. Test my puppet configuration is working properly: required packages are installed, services are running and expected directories/files are created.
  2. Test my nginx configuration – make sure it is correctly configured to server static files and proxies the requests to WSGI.
  3. Test my fabric commands – I use the fabric command to install my blog application on the server and to control the HTTP server.
  4. I run my Django application in a virtual python environment using virtualenv. I can test the virtual environment in this isolated virtual machine.

The best part is that if I corrupt my virtual machine’s environment, I can bring a fully-functional machine in matter of minutes by using puppet and fabric. You no longer need to be afraid of making mistake and spending hours reconstructing from scratch. Vagrant + Puppet + Fabric gives you freedom to explore and try fun ways to running a server.

Leave a Reply