Some new features like parallel are handy but require an updated version of fabric. Here is a safe and clean way of installing Fabric in a more Pyhonic fashion. This should also work just fine on other distros that use aptitude or apt-get and this can be an exercise to the reader to figure out how to do this with yum or urpmi.
Using PIP is a great way to install Python software
root@desky# aptitude install python-pip python-dev build-essential
add the --upgrade flag if you have an older version install. PIP will upgrade packages installed from the distro package which is both dangerous and cool.
root@desky# pip install fabric --upgrade
Its that easy...
Create a fabfile.py to work with.
from __future__ import with_statement # needed for python 2.5
import os
from fabric.api import *
from fabric.contrib.files import comment, sed
env.user = 'root'
env.password = 'reallygoodpassword'
#env.key_filename = '~/.ssh/id_rsa.pub'
def myhosts():
env.hosts = ['10.30.71.21','10.30.71.22','10.30.71.23','10.30.71.24','10.30.71.25','10.30.71.26','10.30.71.27','10.30.71.28','10.30.71.29']
@parallel(pool_size=3)
def pool():
run('ping -i 1 -c 5 10.0.64.1')
@parallel
def fast():
#run('whoami')
run('ping -i 1 -c 5 10.0.64.1')
@serial
def slow():
#run('whoami')
run('ping -i 1 -c 5 10.0.64.1')
Then you can play with the commands in serial..
root@desky# fab myhosts slow
or parallel...
root@desky# fab myhosts fast
or parallel with a pool size set
root@desky# fab myhosts pool