Fabric: simple pythonic deployment.
Please take note: Fabric has changed hands, is due for a major new release, and is moving!
For the news, see the official announcement by Christian and the followup with details from Jeff.
The Git repositories have already moved:
- The official, canonical repository is git.fabfile.org
- The official Github mirror is GitHub/bitprophet/fabric
A new website at fabfile.org will be up shortly, at the same time that the first alpha release goes out. This website at nongnu.org will remain active to serve as documentation for users of 0.1 and older; however, we strongly urge all users to plan an upgrade to version 0.9 once it is released in final form, and to consider this website and its contents to be obsolete.
Fabric is a simple pythonic remote deployment tool.
It is designed to upload files to, and run shell commands on, a number of servers in parallel or serially. These commands are grouped in tasks (regular python functions) and specified in a 'fabfile.'
This is called remote automation, and the primary use case is deploying applications to multiple similar hosts.
Although it is easier to automate when the target hosts are similar, it is not a requirement and Fabric has features for working with heterogeneous hosts as well.
Once installed, you can run fab help to learn more about how to use Fabric.
Installing
... is as easy as:
$ sudo easy_install Fabric
To get the most out of Fabric, your system needs to live up to some requirements:
- Python 2.5 (2.4 might work but is not tested).
- Python Setuptools (part of most python installations).
- Paramiko 1.6 or greater (requires pycrypto).
- A unix environment (cygwin might work but is not tested).
Fabfiles
They're called 'fabfiles.' You put them in the root of your project directory, and the filename is 'fabfile' or 'fabfile.py.' Their purpose is to describe the commands to use and the steps to take, when you run a command with Fabric.
And, in the simplest form, they look like this:
config.project = 'awesome-app'
config.fab_hosts = ['n1.cluster.com', 'n2.cluster.com']
def deploy():
"Build the project and deploy it to a specified environment."
local('mvn package')
put('target/$(project).war', '$(project).war')
put('install-script.sh', 'install-script.sh')
sudo('install-script.sh')
Then run it like this from the command line:
$ fab deploy
License
The Fabric program and scripts are released and distributed under the GPL v. 2 license.
The Fabric 'F' logo and the documentation are released under a Creative Commons license.