Created
September 16, 2012 12:47
-
-
Save Bouke/3732305 to your computer and use it in GitHub Desktop.
fabric test: hosts/roles command line overrides
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 * | |
## hosts | |
@task | |
@hosts('a') | |
def first(): | |
execute(second) | |
@task | |
@hosts('b') | |
def second(): | |
pass | |
# $ fab first | |
# [a] Executing task 'first' | |
# [b] Executing task 'second' | |
# $ fab first -H c | |
# [a] Executing task 'first' | |
# [b] Executing task 'second' | |
# $ fab first:hosts=c | |
# [c] Executing task 'first' | |
# [b] Executing task 'second' | |
## roles | |
env.roledefs = { | |
'd': ['host-d'], | |
'e': ['host-e'], | |
} | |
@task | |
@roles('d') | |
def third(): | |
execute(forth) | |
@task | |
@roles('e') | |
def forth(): | |
pass | |
# $ fab third | |
# [host-d] Executing task 'third' | |
# [host-e] Executing task 'forth' | |
# $ fab third -H c | |
# [host-d] Executing task 'third' | |
# [host-e] Executing task 'forth' | |
# $ fab third:hosts=c | |
# [c] Executing task 'third' | |
# [host-e] Executing task 'forth' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment