Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sudotest(cmd="echo TEST"):
- with hide('status','warnings','stderr', 'stdout','running','everything','status'), settings(warn_only=True):
- env.abort_on_prompts = True
- try:
- result=sudo("%s" % cmd)
- if (result.succeeded):
- print(env.host + ":SUCCESS")
- else:
- print(env.host + ":FAIL")
- except SystemExit:
- print(env.host + ":FAIL")
- except:
- print(env.host + ":FAIL - catchall")
- [host1] Executing task 'sudotest'
- host1 :SUCCESS
- host2 :SUCCESS
- [host1] Executing task 'sudotest'
- [host1] out: Sorry, try again.
- [host1] out: sudo password:
- Fatal error: Needed to prompt for a connection or sudo password (host: host1), but abort-on-prompts was set to True
- Aborting.
- host1 :FAIL
- [host2] out: Sorry, try again.
- [host2] out: sudo password:
- Fatal error: Needed to prompt for a connection or sudo password (host: host2), but abort-on-prompts was set to True
- Aborting.
- host2 :FAIL
- env.disable_known_hosts = True
- env.skip_bad_hosts = True
- env.remote_interupt = True
- env.warn_only = True
- env.eagerly_disconnect = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement