A bunch of Python Fabric scripts to work with Vagrant and EC2 Ubuntu servers
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Fabric Scripts

This is a group of Python Fabric scripts to interact with Ubuntu servers, in particular Vagrant and EC2 instances.

I grew tired of copying files around for each project (and then losing track of what was updated where), and did a bit of research on how to use submodules in Git (which is pretty straight forward).

I am far from being a SysAdmin, and that is reflected in the quality of the scripts, but in some cases they are doing the trick (for my customers at least).

The way in which I use them is to add this project as a submodule in git, and then create a fabfile.py in my parent directory with the content:

from fabric_scripts import scripts

Then, when I do a fab -l in my directory, I get a list in the form of:

EduardoMacBookPro:vagrant_research eduardoshanahan$ fab -l

Available commands:	

	scripts.call_vagrant                        Contact a Vagrant instance
	scripts.development.tools.install           Get some tools
	scripts.docker.install                      Install Docker.io

Tools that I use in my development machine

  • Python 2.7

Make sure that you aim to the right version. In the Mac I managed to have three different 2.7* versions, and who knows which one is being used each time. Now and then I do a cleanup and remove what I don't think I need, but somehow more versions appears after a while. The problem is that some Python tools (like pip, or Fabric) sometimes get assigned to the wrong version, and doesn't work although they are installed. Specifying the path usually sort the problem, but it is only a hack. Ubuntu is a lot more stable.

python --version should say something like Python 2.7.8 which python will tell you where is the binary, something like /usr/local/bin/python

  • Python-dev

In some cases (as in Suse machines) the python-dev package has to be installed for Pip to compile.

Pip is a Python package manager. It basically makes your life easier when you need some third party tool. Installation instructions are on the link.

pip --version should answer pip 1.5.6 ...

Download a version for your operating system and install it as any other application. Install the extension pack too (it will be asked the first time you run the UI).

After being installed, create a machine using the user interface, to make sure that VB is working fine (this step will require an ISO file for an operating system). You should be able to start and stop the instance, and to connect to it. If you are confident, you can skip the test and jump straigth to Vagrant, but if something bombs you will have to come back and ensure that VirtualBox is working properly.

Vagrant creates and fire up instances using Virtual Box. It is easy to configure and cheap in machine resources (I run between three to five instances most of the day in an I7/8GB Mac without troubles)

vagrant version should answer with Vagrant 1.6.5 or more.

Just follow the instrucctions on the page.

`pip install boto' should be enough.

I installed Fabric using pip (pip install fabric). After all is done, a call for fab --version should answer Fabric 1.10.0 or newer.

After all the tools are installed, we are going to script the whole deployment makingFabric scripts. In the case of Vagrant, after the machine is fired up, you can install tools automatically, and doing that will require extra Vagrant tools. With an Ubuntu host, you might need a plugin to do provisioning from Fabric.

Vagrant plugin

To have the machine doing automatic provisioning, we will probably need a plugin in Vagrant to understand how to work with Fabric. After checking that everything works as expected between VirtualBox, Vagrant and Fabric, run the following command:

vagrant plugin install vagrant-fabric