Lamont,

It's honestly been a while since I used fabric and have not really stayed
up on it so apologies if my research was too hastily done and incorrect.
There does seem to be the functionality you are looking for in both fabric
1 and 2 (alpha) though they have some slight differences.

In fabric 1.x it came from here:
https://github.com/fabric/fabric/blob/1.14/fabric/context_managers.py like
this:
https://github.com/fabric/fabric/blob/1.14/fabric/context_managers.py#L20-L21

In fabric 2.x they broke out that into the invoke library here:
https://github.com/pyinvoke/invoke/blob/master/invoke/context.py like this:
https://github.com/pyinvoke/invoke/blob/master/invoke/context.py#L328-L329

Hope this helps,


On Tue, Oct 10, 2017 at 7:05 PM, Lamont Nelson <lamont.nel...@gmail.com>
wrote:

> 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
>
>
>
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>


-- 
Ben Abrams
Computer Consultant
702-900-7926
benabrams.it
m...@benabrams.it
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to