I recently started using Fabric to simplify my deployment process.
Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
I quite like Fabric – I’m not 100% sold, but it’s easy to get started with and it won’t be long until you can write complex scripts.
Being able to deploy a complex app with a single command is great. I do not miss long checklists and having to run through step after step in a hurry.
fab deploy
Pretty easy isn’t it?
Why Fabric? To be honest – why not. I know a little bit of Python, so why not learn a bit more? I like the glueyness, the fact that it (mostly) lets you get on with things and doesn’t force you to work in a particular way.
I had a devil of a time getting it up and running though on my Mac running 10.6.8 (Snow Leopard).
Getting started…
Homebrew http://mxcl.github.io/homebrew/
is a package manager for OSX and alternative to MacPorts. Install Fabric and Python via Homebrew to (hopefully) make your life a bit easier…
Install Homebrew
Open a terminal. Run the commands as your user, not sudo
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Install Homebrew and then check the install.
brew doctor
Running brew doctor
will identify any problems with your install. Any problems are displayed. Work through any issues it flags up one by one. In my case I ended up having to remove MacPorts and had to reinstall Xcode.
Remove MacPorts
MacPorts is another package manager, but apparently it often doesn’t play with Homebrew.
Follow the instructions http://guide.macports.org/chunked/installing.macports.uninstalling.html
sudo port -fp uninstall installed
sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports
Remove Xcode
Xcode is Apple’s Integrated Development Environment (IDE) containing tools for developing software for OS X and iOS.
Based on issues listed by brew doctor
I removed Xcode and the re-installed it.
sudo /Developer/Library/uninstall-devtools --mode=all
Make sure you have your Apple ID to hand if you don’t have the .dmg and need to download it from Apple.
Install Git
Next I installed Git using Homebrew if you do not already have it (I use Mercurial day to day, so I didn’t)
brew install git
brew upgrade git
Install python
brew install python
Update your paths to use the version of Python that you’ve just installed.
sudo nano /etc/paths
nano ~/.bashrc
Install Fabric
pip install fabric
Edit: To install Fabric you need to use the pip package manager which was installed as part of Python.
Phew! Everything should be working now… time to write a fabfile.py
Shouldn’t that be (sudo) pip install fabric instead of brew install fabric?
Hi Lee
In this case the aim is to try and keep everything within homebrew – having had bad experiences in the path, I just wanted to keep things as clear as possible.
Homebrew installs its software in /usr/local – OSX doesn’t install anything there (it should only contain what you install).
Pip install files into system directories by default, which is why you need to use sudo when you install things with them.
Cheers
Hi Lee
You know, I think I may owe you an apology – just revisiting this (setting everything up on a clean install of OSX Mavericks) and I did have to use pip to install Fabric. I’m not sure if Fabric never existed as a standard Homebrew package or whether this is simply the case now.
Anyway I’m making an updated post.