fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] fabric2 cd with multiple servers


From: Lamont Nelson
Subject: [Fab-user] fabric2 cd with multiple servers
Date: Tue, 10 Oct 2017 22:05:04 -0400

I'm learning the fabric2 api and wanted to know the best way to run a command with a particular working directory on a set of servers.

The README indicates that there is a 'execute' method on Group, but this doesn't seem to be the case. I was able to get code below to work by calling run on each connection in the group. Is there a more succinct way to do this besides the "cd foo && cmd" method? Or am I overlooking something?

-----
from fabric import ThreadingGroup
g=ThreadingGroup('host1','host2')
g.run('cd /tmp && ls foo')

-- or --

from fabric import ThreadingGroup
g=ThreadingGroup('host1','host2')
for c in g:
    with c.cd('/tmp'):
        c.run('ls foo')
-----

Regards,
Lamont




reply via email to

[Prev in Thread] Current Thread [Next in Thread]