Nested Fabric tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from fabric.api import task, run, hosts, cd, env, local | |
| from fabric.operations import put | |
| @task | |
| @hosts('root@10.0.0.9') | |
| def host1task(): | |
| put(os.path.abspath('fabfile1.py'),'/tmp/') | |
| run('fab -f /tmp/fabfile1.py host2task') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fabric.api import task, run, hosts, cd, env, local | |
| from fabric.operations import put | |
| @task | |
| @hosts('root@10.0.0.27') | |
| def host2task(): | |
| run('uname -a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [gene@zion64 ~]$ fab -f /home/gene/fabfile.py host1task | |
| [root@10.0.0.9] Executing task 'host1task' | |
| [root@10.0.0.9] Login password for 'root': | |
| [root@10.0.0.9] put: /home/gene/fabfile1.py -> /tmp/fabfile1.py | |
| [root@10.0.0.9] run: fab -f /tmp/fabfile1.py host2task | |
| [root@10.0.0.9] out: [root@10.0.0.27] Executing task 'host2task' | |
| [root@10.0.0.9] out: [root@10.0.0.27] run: uname -a | |
| [root@10.0.0.9] out: [root@10.0.0.27] Login password for 'root': | |
| [root@10.0.0.9] out: [root@10.0.0.27] out: Linux zion64 3.5.0-2.fc17.x86_64 #1 SMP Mon Jul 30 14:48:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux | |
| [root@10.0.0.9] out: Done. | |
| [root@10.0.0.9] out: Disconnecting from 10.0.0.27... done. | |
| Done. | |
| Disconnecting from root@10.0.0.9... done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ignore the unused imports, btw.