You're executing mycallable in your env.roledefs definition. Remove the "()" from the end and it should work as advertised.
On Mon, Jan 4, 2016 at 10:01 PM James Litton <[email protected]> wrote: > I’m having an issue with using callables for env.roledefs. The > documentation suggests that they will only be called when executing a task > that uses the role: > In addition to list/iterable object types, the values in env.roledefs (or > value of hosts key in dict style definition) may be callables, and will > thus be called when looked up when tasks are run instead of at module load > time. (For example, you could connect to remote servers to obtain role > definitions, and not worry about causing delays at fabfile load time when > calling e.g. fab --list.) > > This does not appear to be the case from the following simple example also > I could not find a corresponding bug ticket, please let me know if one > already exists: > from fabric.api import * > > def mycallable(): > print "called" > return ["x.example.com"] > > env.roledefs = { > "test": mycallable() > } > > @task > def mytask(): > print "Mytask called on %s" % env.roles > > > $ fab --list fabfile.py > called > Available commands: > > Mytask > > $ fab --version > Fabric 1.10.2 > Paramiko 1.16.0 > > Thank you for your help, > James Litton > [email protected] > _______________________________________________ > Fab-user mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user >
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
