File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,41 @@ Systems Administration
44Fabric
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
943Chef
1044----
You can’t perform that action at this time.
0 commit comments