Fabric – Parallel execution

Fabric 1.3.0 comes with a great new feature that allows parallel execution of fabric tasks. Also the serial execution is still available which I think is still very useful. I did a small test to see how the new feature behaves.

This was tested on virtual Xubuntu 11.04 running on VirtualBox 4.1.2.

14:51 26.10.2011
Installed a new version of Fabric (1.3.1):
wget http://git.fabfile.org/cgit.cgi/fabric/snapshot/fabric-1.3.1.tar.gz
tar -xf fabric-1.3.1.tar.gz
cd fabric-1.3.1
sudo python setup.py install

Here’s the contents of the fabfile.py that I used:

from fabric.api import *

env.user='ubuntu'
env.password='ubuntu'

def status():
    run("uptime")
    run("uname -a")

15:09 26.10.2011
Tried the new parallel execution option -P with our status task on two virtual machines:
hng@hng-VirtualBox:~$ fab -P status:hosts="hng@192.168.100.48;hngu@192.168.100.36"
[hng@192.168.100.48] Executing task 'status'
[hngu@192.168.100.36] Executing task 'status'
[hngu@192.168.100.36] run: uptime
[hng@192.168.100.48] run: uptime
[hngu@192.168.100.36] Login password: [hng@192.168.100.48] Login password:
[hngu@192.168.100.36] out:  15:09:48 up  6:37,  3 users,  load average: 0.00, 0.01, 0.05
[hngu@192.168.100.36] run: uname -a
[hngu@192.168.100.36] out: Linux hngu-VirtualBox 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

(Here I pressed Enter to continue)

Sorry, you can't enter an empty password. Please try again.
[hng@192.168.100.48] Login password:
[hng@192.168.100.48] out:  15:10:13 up 18:57,  3 users,  load average: 0.71, 0.22, 0.13
[hng@192.168.100.48] run: uname -a
[hng@192.168.100.48] out: Linux hng-VirtualBox 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011 i686 i686 i386 GNU/Linux

Done.

15:12 26.10.2011
Now for some reason after this my terminal doesn’t show anything I type. I think it could be related to the password prompt during the task as it turns off echoing of stdin data and it somehow stays like that after the task has finished.

15:33 26.10.2011
If I run the task so that the password won’t get prompted (using env.password), everything works just fine and the terminal works perfectly after running the task. So the problem was caused by the password prompt. Here’s the output:

hng@hng-VirtualBox:~$ fab -P status:hosts="192.168.100.48;192.168.100.36"
[192.168.100.48] Executing task 'status'
[192.168.100.36] Executing task 'status'
[192.168.100.36] run: uptime
[192.168.100.48] run: uptime
[192.168.100.36] out:  15:33:47 up  7:01,  3 users,  load average: 0.33, 0.10, 0.07
[192.168.100.36] run: uname -a
[192.168.100.36] out: Linux hngu-VirtualBox 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

[192.168.100.48] out:  15:33:50 up 19:21,  4 users,  load average: 0.34, 0.12, 0.09
[192.168.100.48] run: uname -a
[192.168.100.48] out: Linux hng-VirtualBox 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011 i686 i686 i386 GNU/Linux

Done.

15:28 26.10.2011
Besides the weird behavior with the password prompt, the new parallel execution option seems to work quite nicely.

About these ads

, , , , , , , , , , , , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: