Skip to content

Commit dbb1ec6

Browse files
author
Steve Pulec
committed
Adding Fabric overview and example
1 parent 8b25109 commit dbb1ec6

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

docs/scenarios/admin.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,41 @@ Systems Administration
44
Fabric
55
------
66

7-
.. todo:: Write about Fabric
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.
10+
11+
Install Fabric:
12+
13+
::
14+
15+
pip install fabric
16+
17+
The following code will ssh into both of our servers, cd to our project
18+
directory, activate the virtual environment, pull the newest codebase,
19+
and restart the application server.
20+
21+
::
22+
23+
from fabric.api import env, cd, run, prefix
24+
25+
env.hosts = ['my_server1', 'my_server2']
26+
27+
def deploy():
28+
with cd('/var/www/project-env/project'):
29+
with prefix('. ../bin/activate'):
30+
run('git pull')
31+
run('touch app.wsgi')
32+
33+
With the previous code saved in a file named fabfile.py, we merely need to run
34+
the following command to deploy our application to both of our servers.
35+
36+
::
37+
38+
$ fab deploy
39+
40+
Additional features include parallel execution, interaction with remote
41+
programs, and host grouping.
842

943
Chef
1044
----

0 commit comments

Comments
 (0)