Last active
December 20, 2015 10:39
-
-
Save 198d/6117122 to your computer and use it in GitHub Desktop.
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 run, task, roles, env, execute | |
env.roledefs = {'web': ['host1.example.com', | |
'host2.example.com'], | |
'db': ['host3.example.com']} | |
@task | |
@roles('db') | |
def echo(): | |
run('echo db') | |
@task | |
@roles('web') | |
def test(): | |
run('echo web') | |
execute(echo) |
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
$ fab test | |
[host1.example.com] Executing task 'test' | |
[host1.example.com] run: echo web | |
[host1.example.com] out: web | |
[host1.example.com] out: | |
[host3.example.com] Executing task 'echo' | |
[host3.example.com] run: echo db | |
[host3.example.com] out: db | |
[host3.example.com] out: | |
[host2.example.com] Executing task 'test' | |
[host2.example.com] run: echo web | |
[host2.example.com] out: web | |
[host2.example.com] out: | |
[host3.example.com] Executing task 'echo' | |
[host3.example.com] run: echo db | |
[host3.example.com] out: db | |
[host3.example.com] out: | |
Done. | |
Disconnecting from host1.example.com... done. | |
Disconnecting from host2.example.com... done. | |
Disconnecting from host3.example.com... done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment