James Litton
2016-01-05 03:00:54 UTC
Im 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
***@quantcast.com
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
***@quantcast.com