Skip to content

Instantly share code, notes, and snippets.

@exhuma
Last active January 2, 2016 19:18
Show Gist options
  • Save exhuma/8348976 to your computer and use it in GitHub Desktop.
Save exhuma/8348976 to your computer and use it in GitHub Desktop.
Transcript for comment on http://stackoverflow.com/a/17724207/160665
┌─[10:15:19] michel@PC12-331
└─~/tmp› cat fabfile.py
import fabric.api as fab
fab.env.roledefs['staging'] = ['bbs-evolution.ipsw.dt.ept.lu']
fab.env.roledefs['prod'] = ['bbs-arbiter.ipsw.dt.ept.lu']
@fab.task
def mytask():
print fab.env.roles
print fab.run('hostname')
┌─[10:15:24] michel@PC12-331
└─~/tmp› fab mytask:roles="staging,prod"
[bbs-evolution.ipsw.dt.ept.lu] Executing task 'mytask'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
multiprocessing
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 264, in _execute
return task.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
return self.wrapped(*args, **kwargs)
TypeError: mytask() takes no arguments (1 given)
┌─[10:16:26] michel@PC12-331
└─~/tmp› fab mytask -R "staging,prod"
[bbs-nexus.ipsw.dt.ept.lu] Executing task 'mytask'
['staging', 'prod']
[bbs-nexus.ipsw.dt.ept.lu] run: hostname
[bbs-nexus.ipsw.dt.ept.lu] out: BBS-nexus.ipsw.dt.ept.lu
[bbs-nexus.ipsw.dt.ept.lu] out:
BBS-nexus.ipsw.dt.ept.lu
[bbs-pylon.ipsw.dt.ept.lu] Executing task 'mytask'
['staging', 'prod']
[bbs-pylon.ipsw.dt.ept.lu] run: hostname
[bbs-pylon.ipsw.dt.ept.lu] out: BBS-pylon.ipsw.dt.ept.lu
[bbs-pylon.ipsw.dt.ept.lu] out:
BBS-pylon.ipsw.dt.ept.lu
Done.
Disconnecting from bbs-nexus.ipsw.dt.ept.lu... done.
Disconnecting from bbs-pylon.ipsw.dt.ept.lu... done.
@rockallite
Copy link

Should be fab mytask:roles="staging;prod". Use semi-colon, not comma.

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