Reputation: 415
I want to try to execute this
env.host_string = "server1.com"
with cd("/tmp"):
run("some command)
#switch servers
env.host_string = "server2.com"
with cd("/home"):
run("some other command")
The issue is the commands need to be executed sequentially and not in parrelel. I can't figure out a way to do this in fabric. I've tried with env("hostname"):
but that does not work.
Upvotes: 0
Views: 36
Reputation: 11
You can accomplish this using fabric's execute()
task_a():
with cd("/tmp"):
run("some command")
task_b():
with cd("/home"):
run("some other command")
task_c():
execute(task_a,hosts=["server1.com"])
execute(task_b,hosts=["server2.com"])
Upvotes: 1
Reputation: 2099
Use the @serial decorator to avoid parallel execution of tasks. You could also try the @hosts decorator (see the same page) to limit each task to a subset of hosts, and argue all hosts when you call Fabric.
Upvotes: 1