Lamont Nelson
2017-10-11 02:05:04 UTC
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
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