Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabric 2 - Execute a task on a Group (with arguments) #1691

Open
haydenflinner opened this issue Dec 8, 2017 · 5 comments
Open

Fabric 2 - Execute a task on a Group (with arguments) #1691

haydenflinner opened this issue Dec 8, 2017 · 5 comments
Milestone

Comments

@haydenflinner
Copy link

I've got a task that has arguments. I'd like to run this task on a group of hosts, with a different argument to the task depending on the host, from within another Python script.

The comment within execute says to implement it as per the tutorial. Can I get a link to this tutorial? And if I get it working /get it working with arguments being passed through, would this be a welcome pull request?

@ploxiln
Copy link

ploxiln commented Dec 8, 2017

I think this is the closest thing to a Fabric 2 tutorial: http://docs.fabfile.org/en/stable/getting_started.html

@bitprophet
Copy link
Member

I'd like to run this task on a group of hosts, with a different argument to the task depending on the host, from within another Python script.

Not knowing your exact use case, and noting that Group isn't super well fleshed out yet (focus has been on getting Connection in good shape), I'll point out that so far, Group has been conceived as a convenience/wrapper API only - it's the common case of "I give you a list of hostnames and a thing to do and you do it for me, without me having to write my own loop."

For anything more complex, the idea is it should still be quite easy to do it yourself using manually-instantiated Connections within whatever Python construct fits your use case (iterating, etc.) So in this case, you'd have a 'meta' task performing something like for hostname, kwargs in my_map_of_hostnames_to_kwargs.items(): othertask(Connection(hostname), **kwargs).

(That still leaves pyinvoke/invoke#170, or less likely, #4, but for now both of those are work-aroundable.)

If you supply details about the use case, maybe one of us can elaborate further.


Re: tutorial: yea the 'getting started' page is the tutorial, the specific bit that pretends to know about Group.execute is http://docs.fabfile.org/en/v2/getting_started.html#bringing-it-all-together - but as above, the behavior isn't really thought out yet!

@haydenflinner
Copy link
Author

haydenflinner commented Dec 13, 2017

Thank you so much for this v2 tutorial. I had found the source of it on GitHub but neglected to read around it.

cxn = Connection(host) is the critical bit I was missing; the parts of the tutorial I had found made no mention of what cxn was, and I didn't dig enough to figure out it was just a Connection.

I've already written the code that I needed when I posted this using the Fabric3 port, but with a mind towards moving to v2 once it's on PyPi. Thanks for your time guys!

Edit: It might help future potential users if you added a link to that v2 tutorial into the README here. I'd pull request it but that seems like a bit much for a one line change :p

@revolter
Copy link

Can't the host be automatically loaded from the fabric.json config file instead of passing it to the -D argument on the command line?

@breisig
Copy link

breisig commented Sep 20, 2019

This feature is greatly needed for Fabric2. Any idea when it will be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants