Discussion:
[Fab-user] using execute fabric command does not work as expected
Alexander Kolev
2013-09-13 11:23:27 UTC
Permalink
Hi,



I'm using Fabric 1.7, Python 2.7. This is part of my fabfile.py file



env.roledefs = {

"dev" : ["dev01 "],

"staging" : ["sta01 ", "sta02"],

"live" : ["live01", "live02"]



@roles("staging")

def stage(application=""):

execute(create_package)

execute(copy_package)

execute(run_package)

execute(email_result)





When I call fab stage:appname, it runs the four functions first on sta01 and
then on sta02.



Sta01: create_package

Sta01: copy_package

Sta01: run_package

Sta01: email_result





Sta02: create_package

Sta02: copy_package

Sta02: run_package

Sta02: email_result





Expected result is executing each function on sta01 and sta02, and then
continue with next function:



Sta01: create_package

Sta02: create_package





Sta01: copy_package

Sta02: copy_package



Sta01: run_package

Sta02: run_package



Sta01: email_result

Sta02: email_result





What is wrong with my script?





Regards,

Alex
Jeff Forcier
2013-09-13 20:33:42 UTC
Permalink
Please check the usage docs on the execution model - I think what you
want is to remove @roles from your function and instead give the inner
execute() calls 'role='staging'.

By putting @roles on stage() you're telling Fabric to run that task
once per host in the role's runlist - instead you want stage() itself
to just run one time "locally" and for the inner execute()s to handle
connecting per-subtask. Thus the role= kwarg to execute().
Hi,
I’m using Fabric 1.7, Python 2.7. This is part of my fabfile.py file
env.roledefs = {
"dev" : ["dev01 "],
"staging" : ["sta01 ", "sta02"],
"live" : ["live01", "live02"]
@roles("staging")
execute(create_package)
execute(copy_package)
execute(run_package)
execute(email_result)
When I call fab stage:appname, it runs the four functions first on sta01 and
then on sta02.
Sta01: create_package
Sta01: copy_package
Sta01: run_package
Sta01: email_result
Sta02: create_package
Sta02: copy_package
Sta02: run_package
Sta02: email_result
Expected result is executing each function on sta01 and sta02, and then
Sta01: create_package
Sta02: create_package
Sta01: copy_package
Sta02: copy_package
Sta01: run_package
Sta02: run_package
Sta01: email_result
Sta02: email_result
What is wrong with my script?
Regards,
Alex
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org
Loading...