Skip to content

Installing Fabric on CentOS 5

April 3, 2012

Fabric is a great tool for performing remote tasks that need to be done on a group of hosts. It allows a sysadmin to run commands both locally and remotely, copy and send files, and even execute commands using sudo on the remote end.

For our current POC configuration, Eucalyptus still recommends CentOS 5. Unfortunately, getting Fabric to install and work with CentOS 5 is a bit of pain. I’ve finally figured out what is needed for Fabric to work. This will allow for future blogs about utilizing Fabric with Eucalyptus.

1. Install the EPEL repository for CentOS 5 and install python26, python26-devel, gcc, and python-setuptools

# curl -o epel-release-5-4.noarch.rpm http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uhv epel-release-5-4.noarch.rpm
# yum install -y python26 python26-devel gcc python-setuptools

2. Make setuptools available to python26

# cp -R /usr/lib/python2.4/site-packages/setuptools* /usr/lib/python2.6/site-packages/
# cp -R /usr/lib/python2.4/site-packages/pkg_resources.py* /usr/lib/python2.6/site-packages/

3. Download the latest tarball of the Fabric master branch from GitHub at https://nodeload.github.com/fabric/fabric/tarball/master

# curl -o fabric.tgz https://nodeload.github.com/fabric/fabric/tarball/master
# tar xzvf fabric.tgz
# cd fabric-fabric-

4. Run setup.py to install Fabric from the tarball.

# python26 setup.py install

Optional: Since setuptools was installed from the EPEL repository it is built using a sets module that is deprecated in Python 2.6. If you would like to get rid of the “DeprecationWarning” message when you run fab use the following:

# sed -i 's#/usr/bin/python26#/usr/bin/python26 -W ignore::DeprecationWarning#' /usr/bin/fab

Note: Tip found at HACKTUX | Ignore Python Deprecation Warnings

Now that fabric is installed on our CentOS 5 host we can now run a small test. Create the following fabfile.py that will print out the /etc/redhat-release file when using the release() method in the fabfile.py.

from fabric.api import local

def release():
    local("cat /etc/redhat-release")

You can now execute the above fabfile.py by executing fab while in the same directory as the above created fabfile.py.

# fab -H localhost release
[localhost] Executing task 'release'
[localhost] run: cat /etc/redhat-release
[localhost] Login password: 
[localhost] out: CentOS release 5.8 (Final)
Done.
Disconnecting from localhost... done.

If you get something similar to the output above then your Fabric installation is now setup and ready to go. You can now use fabric on any local or remote management tasks you might need to do on a single machine or a group of hundreds. Fabric is also great for usage with AWS or Eucalyptus instances and I hope to get into a few use cases for using fabric with the cloud in the future.

These instructions can be tweaked to get pip-python working with CentOS 5 as well. With python-pip you have a vast assortment of available utilities and libraries for python as part of the PyPI. If there is any interest in these steps let me know and I’ll throw together a quick blog about getting pip-python to work.

If you want to learn more about using fabric then check out the fabric website and the fabric tutorial.

Edit: Added a script for this setup. Find it on GitHub in my Blog Scripts repo under fabric_on_centos.

From → Automation, Cloud

One Comment
  1. Jon permalink

    Much Appreciated. Thanks.

Leave a comment