Fabric is a Python module for system administrations. It can be considered a tiny Puppet. I needed to gather some info about remote servers, etc without installing an application and I was looking for a Python one that I found this. See more information on fabfile.org.
It is very nice for Python lovers as you can write your scripts in Python…
It is almost well documented but the problem I had with its HelloWorld was that it failed at the first run in Solaris which was annoying (see below why)
Anyway, These are the points I found the hard way. They either were not in the documentation or were deep hidden:
- By default run() method calls “bash -l -c” to execute commands. In Solaris there is no -l so you need to change this default by setting: env.shell = ‘/bin/bash -c’
- Default script file name should be fabfile.py and run it with the fab command.
- List of host names can be set in env.hosts=[…] as a list or passed in to a method using @hosts([…]) annotation
- Not sure if we can use a jumpbox (tunnel through) in version 1.4. It seems available on 1.5 that I haven’t installed yet. My requirement is for A to ssh to C where the connection is through B as A can only connect to B and B can ssh to C and A cannot directly ssh to C (A->B->C)
- fabric module depends on ssh and crypto modules to name a few.
- You hide execution and outputs by:
fabric.state.output[‘running’] = False
fabric.state.output[‘stdout’] = False
In 1.5 you can use hide() method. There is a bug on hide() in 1.4.