Starting with Fabric

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.

Advertisements

My RaspberryPi

My RaspberryPi

This is my latest toy. Although it is one of the cheapest but one of the most interesting ones!

I bought is from au.element14.com in Australia and ordered a case off ebay that I broke while putting it together! It was one of the transparent ones and very fragile. You do not really need a case for it.

I will not go into details of how to set this up as you can find a lot of info on the web.

Just a few notes:

  • For me copying the image to SD took about 10 minutes.
  • Power is through the USB port of my router
  • The desktop Linux is quite responsive but do not expect much from it
  • I enabled ssh and connect to it only remotely. Lynx browser is of some help sometimes !

I am planning to use it as a proxy/firewall in front of my router so currently installing a proxy server into it. I will try to use GPIO ports in the future.