I’ve been a big fan of the fabric project for a long time now. It has made my life very easy in the past and gets better with each new release. Well a few weeks ago I got introduced to a fork of the project by Tav. It provides many new feature additions to fabric and makes fabric a little bit better. So the best way to get it started is via the following
git clone git://github.com/tav/pylibs.git cd pylibs python setup.py export PYTHONPATH=$PYTHONPATH:`pwd`
Once installed, you have to create a fab app
Then you want to add the following contents to it
#!/usr/bin/env python from fabric.main import main main()
Then you want to give it the correct permissions
chmod +x /usr/bin/fab
Now create a directory and place a fabfile.py file in it.
Now create a config.yml file and use the following as a simple template
default: shell: /bin/bash -l -c servers: directory: /dir hosts: - host1.domain.com - host2.domain.com
Then your fab file could look something like
from fabric.api import * env.config_file = 'config.yml' env.user = 'mzupan' @task('servers') def command(): env().multirun('uname -a')
Normally fabric runs in serial, but Tav’s port adds a multirun() function that runs the commands in parallel. BONUS!
Feel free to play around with it and check out his blog post on it to get more commands.