"Fabric is a simple pythonic remote deployment tool."
Less general tool - remote deployment scripting. Similar in function to capistrano. First released Jan 2008, pretty stable pre-1.0 app, Python 2.5 on unix only.
Developed by Jeff Forcier and Christian Hansen
Homepage: http://www.nongnu.org/fab/
Sad truth of web development - deployment strategy in the past frequently consisted of
Remote deployment tool should
Fabric is a framework for building a command line tool that easily accomplishes these tasks.
Create file fabfile.py. Functions in fabfile.py become fab commands accessed like:
$ fab function_name
Fabric offers a dozen built in operations - I primarily use
Configuration class supporting keyword arguments or attribute assignment. Fabric expects:
config(fab_hosts=['simeonfranklin.com'], fab_user='simeon') def build(): """Build local resources""" local("ls -l > build.txt") def deploy(): """Copy local resources to remote host""" put("build.txt","public_html/")
$ fab list Fabric v. 0.1.0. Running list... Available commands are: about : Display Fabric version... *build : Build local resources *deploy : Copy local resources to remote host help : Display Fabric usage help... let : Set a Fabric variable. list : Display a list of commands ... shell : Start an interactive shell ... Done.
$ fab build deploy Running build... [localhost] run: ls -l > build.txt Running deploy... Logging into the following hosts as simeon: simeonfranklin.com Password for simeon@simeonfranklin.com: [simeonfranklin.com] put: build.txt -> public_html/build.txt Done.
def staging(): config.target = "test" def production(): config.target = "public_html" @requires('target', used_for='finding the target deployment dir.', provided_by=['staging', 'production']) def deploy(): """Copy local resources to remote host""" put("build.txt","$(target)/")
$ fab deploy Fabric v. 0.1.0. Running deploy... The 'deploy' command requires a 'target' variable. This variable is used for finding the target deployment dir. Get the variable by running one of these commands: staging production $ fab staging deploy
If you need it! My personal fabfile has about a dozen commands to package my virtualenv and project, transer to the remote server, run a test suite, and restart the appropriate services. 108 lines, docstrings included.
All based on commands/decorators shown so far - and there are only about 5 decorators and a dozen operations in the fabric api all told...
Not just deployment! Great place to store frequently run utility commands (cleaning local cache, #backup# files, etc).
Useful, minimal, easy to learn...
[insert public domain pic of Jim Morrison here]
My only friend, the end...
Questions?