7 Fabric is a library for simplifying system administration tasks. While Chef
8 and Puppet tend to focus on managing servers and system libraries,
9 fabric is more focused on application level tasks such as deployment.
17 The following code will create two tasks that we can use: ``memory_usage`` and
18 ``deploy``. The former will output the memory usage on each machine. The
19 latter will ssh into each server, cd to our project directory, activate the
20 virtual environment, pull the newest codebase, and restart the application
25 from fabric.api import cd, env, prefix, run, task
27 env.hosts = ['my_server1', 'my_server2']
35 with cd('/var/www/project-env/project'):
36 with prefix('. ../bin/activate'):
40 With the previous code saved in a file named fabfile.py, we can check memory
46 [my_server1] Executing task 'memory'
47 [my_server1] run: free -m
48 [my_server1] out: total used free shared buffers cached
49 [my_server1] out: Mem: 6964 1897 5067 0 166 222
50 [my_server1] out: -/+ buffers/cache: 1509 5455
51 [my_server1] out: Swap: 0 0 0
53 [my_server2] Executing task 'memory'
54 [my_server2] run: free -m
55 [my_server2] out: total used free shared buffers cached
56 [my_server2] out: Mem: 1666 902 764 0 180 572
57 [my_server2] out: -/+ buffers/cache: 148 1517
58 [my_server2] out: Swap: 895 1 894
60 and we can deploy with:
66 Additional features include parallel execution, interaction with remote
67 programs, and host grouping.
72 .. todo:: Write about Chef
77 .. todo:: Write about Puppet
82 .. todo:: Write about Blueprint
87 .. todo:: Write about Buildout