You need to have your worker function catch any exceptions ( https://github.com/fabric/fabric/blob/1.14/fabric/exceptions.py) and evaluate success/failure, then return a value useful to you in determining if your task was successful. Returning "None" for failure modes is something I've done before.
On Thu, May 17, 2018 at 11:15 AM Abhijeet Rastogi <abhijeet.1...@gmail.com> wrote: > Anyone? I was hoping if someone can help me with this. > > On Wed, May 16, 2018 at 9:03 PM Abhijeet Rastogi <abhijeet.1...@gmail.com> > wrote: > >> 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 >> >> -- >> Cheers, >> Abhijeet Rastogi (shadyabhi) >> > > > -- > Cheers, > Abhijeet Rastogi (shadyabhi) > _______________________________________________ > Fab-user mailing list > Fab-user@nongnu.org > https://lists.nongnu.org/mailman/listinfo/fab-user >
_______________________________________________ Fab-user mailing list Fab-user@nongnu.org https://lists.nongnu.org/mailman/listinfo/fab-user