info
-
fabric
is a python (2.5-2.7)library
andcommand-line tool
-
for streamlining the use of
ssh
-
for application deployment
-
for system administration tasks
-
installing
-
$ pip install fabric
-
via os’s package manager, package called
fabric
orpython-fabric
$ sudo apt-get install fabric
-
via
conda
$ conda install fabric
demo
-
hello world
-
fabfile.py
$ pico fabfile.py def hello_world(): print 'hello world'
-
run
$ fab hello_world hello world Done.
-
-
hello world with parameter
-
fabfile.py
$ pico fabfile.py def hello_world(username): print 'hello world {}'.format(username)
-
run
$ fab hello_world:hqlgree2 hello world hqlgree2 Done.
-
-
-
fabfile.py
$ pico fabfile.py from fabric.api import run def host_type(): run('uname -s')
-
run
$ fab host_type No hosts found. Please specify (single) host string for connection: localhost [localhost] run: uname -s [localhost] out: Darwin [localhost] out: Done. Disconnecting from localhost... done. $ fab host_type -H localhost,linuxbox
-