Notes on Python deployment using Fabric
I found out about
Fabric via Armin Ronacher's article
Deploying Python Web Applications.
Fabric is a
Capistrano inspired
deployment tool for the Python community. It is very simple
to use. There are 4 main commands: local is
almost like os.system because it runs a command
on the local machine, run and sudo
run a command on a remote machine as either a normal user
or as root, and put transfers a file to a remote
machine.
Here is a sample setup which displays information about the Apache processes on my remote EC2 instance.
- Install Easy Install
- Install Fabric
$ sudo easy_install Fabric
- Create a file called
fabfile.pylocated at~/myprojectNote: for security reasons, you can remove the password from the fabfile and Fabric will prompt for it interactively. Per the documentation, Fabric also supports key-based authentication.def ec2(): set(fab_hosts = ['ec2-65-234-55-183.compute-1.amazonaws.com'], fab_user = 'sofeng', fab_password = 'mypassword',) def ps_apache(): run("ps -e -O rss,pcpu | grep apache")
- Run it
$ cd ~/myproject $ fab ec2 ps_apache
Results:Fabric v. 0.0.9, Copyright (C) 2008 Christian Vest Hansen. Fabric comes with ABSOLUTELY NO WARRANTY; for details type `fab warranty'. This is free software, and you are welcome to redistribute it under certain conditions; type `fab license' for details. Running ec2... Running ps_apache... Logging into the following hosts as sofeng: ec2-65-234-55-183.compute-1.amazonaws.com [ec2-65-234-55-183.compute-1.amazonaws.com] run: ps -e -O rss,pcpu | grep apache [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2163 5504 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2520 15812 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2521 3664 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2522 3664 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2523 3664 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2524 3664 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2619 3664 0.0 S ? 00:00:00 /usr/sbin/apache2 -k start [ec2-65-234-55-183.compute-1.amazonaws.com] out: 2629 1204 0.0 R ? 00:00:00 /bin/bash -l -c ps -e -O rss,pcpu | grep apache Done.
1
Comment
—
Comments feed for this post
Post a comment
About
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »
Search Blog
Tags
-
algorithms
(4)
-
aws
(8)
-
blogproject
(20)
-
c_cplusplus
(12)
-
cardstore
(8)
-
colinux
(2)
-
concurrency
(9)
-
conkeror
(2)
-
cygwin
(18)
-
datastructures
(15)
-
datetime
(3)
-
dell
(3)
-
django
(39)
-
emacs
(20)
-
files_directories
(10)
-
install_setup
(7)
-
javascript
(3)
-
keyboard
(6)
-
matplotlib
(5)
-
mercurial
(4)
-
nginx
(2)
-
preferences
(8)
-
processes
(3)
-
pyqt
(18)
-
python
(122)
-
ratpoison
(3)
-
regexes
(5)
-
rsync
(3)
-
softwaretools
(17)
-
sql
(13)
-
ssh
(7)
-
subversion
(6)
-
twisted
(6)
-
ubuntu
(60)
-
urxvt
(5)
-
vxworks
(25)
-
webservices
(4)
-
wmii
(7)
Blogroll
- Adam Gomaa
- Alex Clemesha
- Amir Salihefendic
- Armin Ronacher
- David Beazley
- David Ziegler
- Duncan McGreggor
- Gareth Rushgrave
- Glyph Lefkowitz
- Guido van Rossum
- Ian Bicking
- Jacob Kaplan-Moss
- James Bennett
- James Tauber
- Jesper Noehr
- Matt Harrison
- Nikolay Kolev
- Parand Darugar
- Peter Baumgartner
- Peter Bengtsson
- Rob Hudson
- Simon Willison
- Will McGugan
#1 Basil Shubin commented on 2009-09-25:
Hmmm... Fabric.. curious.
Nice note ;-)