Streamline sysadmin tasks with fabric

Fabric is a Python command-line tool and library for streamlining sysadmins tasks. It is very useful when you have multiple hosts dedicated for a specific purpose (for example for an elasticsearch cluster) and you want to administer them without the hassle of connecting to each of them individually.

It allows to quickly execute the same command/task on different hosts through ssh. It's one way of doing it though, there are many other alternatives:

I like fabric because it gives you a lot of power thanks to Python. I haven't yet tried parallel-ssh which looks like a good alternative.

Here's a little template I tend to complete depending on the job I have to do. It's a nice starting point if one wants to try fabric

Simply complete the TODO and get going.

An example of the run against 3 different hosts:

$ ./nodes-mgmt.py top
##################################################################
task: "top"
##################################################################
------------ host "node1" -------------
top - 14:11:51 up 1 day, 45 min,  1 user,  load average: 0.98, 0.97, 1.01
------------ host "node0" -------------
top - 14:11:51 up 1 day, 44 min,  1 user,  load average: 1.64, 1.16, 1.10
------------ host "node2" -------------
top - 14:11:52 up 1 day, 45 min,  1 user,  load average: 0.96, 0.96, 1.02

Duration: 0:00:02

Streamline everything !!