Monthly Archives: March 2012

Fabric setup for multiple environments

I recently started using Fabric, an automation tool written in Python that simplifies the process of running various commands and scripts on local and remote servers. If you’re managing remote Linux/*nix servers and haven’t tried this tool (or something similar like Capistrano), definitely check it out. The Fabric documentation is great and will guide you through the process of creating simple and complex scripts that can easily be automated to your various servers.

The only part of the documentation that I found lacking was how best to configure Fabric to run on various groups of servers, and how to define those groups of servers for your project. Below is the basic structure I’ve used to do this, thanks to some guidance from the #fabric IRC channel on Freenode (thanks cnf and bitprophet!)

Because I’m storing in the root of my project directory, and including it with my version control system, I’ve pulled the list of environments and servers out to “”. Once these are in place, doing an rsync of my local codebase to my staging environment is as simple as:

fab e:staging rsync