Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. def sudotest(cmd="echo TEST"):
  2. with hide('status','warnings','stderr', 'stdout','running','everything','status'), settings(warn_only=True):
  3. env.abort_on_prompts = True
  4. try:
  5. result=sudo("%s" % cmd)
  6. if (result.succeeded):
  7. print(env.host + ":SUCCESS")
  8. else:
  9. print(env.host + ":FAIL")
  10. except SystemExit:
  11. print(env.host + ":FAIL")
  12. except:
  13. print(env.host + ":FAIL - catchall")
  14.  
  15. [host1] Executing task 'sudotest'
  16. host1 :SUCCESS
  17. host2 :SUCCESS
  18.  
  19. [host1] Executing task 'sudotest'
  20. [host1] out: Sorry, try again.
  21. [host1] out: sudo password:
  22. Fatal error: Needed to prompt for a connection or sudo password (host: host1), but abort-on-prompts was set to True
  23.  
  24. Aborting.
  25. host1 :FAIL
  26. [host2] out: Sorry, try again.
  27. [host2] out: sudo password:
  28. Fatal error: Needed to prompt for a connection or sudo password (host: host2), but abort-on-prompts was set to True
  29.  
  30. Aborting.
  31. host2 :FAIL
  32.  
  33. env.disable_known_hosts = True
  34. env.skip_bad_hosts = True
  35. env.remote_interupt = True
  36. env.warn_only = True
  37. env.eagerly_disconnect = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement