If you still use FTP or SCP or sFTP to deploy projects, you’re missing out big time on the ease of either Ruby’s Capistrano or Python’s Fabric. Capistrano is almost synonymous with Ruby on Rails, though it is simple to setup with any project. We at Afrigator uses Capistrano to deploy changes to the staging server and to the live servers. It is specially handy if you have to deploy to a cluster of servers. In short, it allows you to execute commands on a remote server(s). For example, you can set it up so that it backs up your files before the deployment or do something and simple and trivial as a directory listing.

Today I came across Fabric, which is a Python version of Capistrano. Now, for the record, my use of Capistrano has been limited. I use it for what I need it. Nothing more. What I’m trying to say is I didn’t go into a very advanced setup of Capistrano, so I’m not really qualified to say which is better. On the Fabric page it says:
It is a bit like a dumbed down Capistrano, except it’s in Python
I like it. Its simple and it is easier than Capistrano IMHO. In the end, it comes down to which tool suits you best! Capistrano does support commits and rollbacks which, by the looks of it, Fabric don’t.
Setting up Capistrano was painless. All I had to do was
sudo gem install capistrano
Fabric had a few dependency issues, which I had to meet first before I could
sudo easy_install Fabric
It was looking for pycrypto which I had to install before I could setup Fabric.
Once installed, using it is as straight forward as Capistrano. All you need to do is to create a fabfile which is a simple python file which holds all the config options and commands to execute remotely. The syntax is plain and simple and clean. Here is a simple example executing a directory listing on a remote server:
def listing():
"Outputs a directory listing on the remote server."
set(fab_user = 'stii')
set(fab_hosts = ['stii.co.za'])
run('ls -l /usr/bin')
Simple. Apart from the run command to execute remote queries, there are also a sudo (execute remote commands as a privileged user), local (execute commands on your local machine) and put (upload files to the remote servers) which is very handy.
I’m going to use it a bit more and would give you more feedback in a while. If you want, you can check it out!
Update: Here is an example of how to upgrade WordPress using Python Fabric