Friday, February 12, 2010

Fabric - A Deployment Tool for Rubyists and Pythonists Alike

If you're coming from the Ruby/Rails world, the industry standard tool for deployment is clearly Capistrano

In some cases, though, using Fabric might make more sense.  If you've got a simple web app and want to try something different for deployment, have a look at Fabric. It's a terse, lightweight Python deployment tool and a good alternative to Capistrano. Most importantly, it's SUPER EASY to learn and you don't need ANY Python experience.

I like how Fabric's tutorial shows a version-control-agnostic deployment pattern. The fabfile is part of the project we want to deploy, and whatever is in our project directory will be deployed. With this pattern, Fabric doesn't need any information about our version control system or repository.

For example, I use git for most of my projects.

If I'm running the master branch on my development machine and want to deploy master, I just run
$ fab deploy
What if I want to deploy my release branch instead of the master branch? I just do the following:
$ git checkout my-release-branch
$ fab deploy

Super easy.  We can manage the code we're deploying with the tools already built in to our version control system; we don't have to implement those controls again with our deployment tool.

Installing Fabric on Ubuntu 9.10
$ sudo apt-get install python-setuptools
$ sudo easy_install fabric

Wow, that was easy.

No comments: