Abhijeet Rastogi
2018-05-16 15:33:53 UTC
Hi everyone,
Let's suppose I have a simple code like this.
from fabric.api import run, env, execute
from fabric import state
env.use_ssh_config = True
env.parallel = True
hosts = ['success.host', 'failure.host']
def get_uptime():
output = run("uptime")
return output
collected_output = execute(get_uptime, hosts=hosts)
for host, output in collected_output.iteritems():
if output is not None:
print("{0}:\n{1}".format(host, output))
How do I continue my execution of code beyond execute method invocation to
print successful hosts output and also give a summary of failed hosts?
I don't want to fabric library to show warnings or exit code when that
happens. I read about envenv.abort_exception but I'm not sure how to use
that to do both things, capture output of successful tasks and show failed
hosts as that exception doesn't have any arguments.
Any help is appreciated
Let's suppose I have a simple code like this.
from fabric.api import run, env, execute
from fabric import state
env.use_ssh_config = True
env.parallel = True
hosts = ['success.host', 'failure.host']
def get_uptime():
output = run("uptime")
return output
collected_output = execute(get_uptime, hosts=hosts)
for host, output in collected_output.iteritems():
if output is not None:
print("{0}:\n{1}".format(host, output))
How do I continue my execution of code beyond execute method invocation to
print successful hosts output and also give a summary of failed hosts?
I don't want to fabric library to show warnings or exit code when that
happens. I read about envenv.abort_exception but I'm not sure how to use
that to do both things, capture output of successful tasks and show failed
hosts as that exception doesn't have any arguments.
Any help is appreciated
--
Cheers,
Abhijeet Rastogi (shadyabhi)
Cheers,
Abhijeet Rastogi (shadyabhi)