Add support for specifying sudo passwords to both ansible & playbook. Nopasswd sudo is no longer required.

This commit is contained in:
Michael DeHaan
2012-04-13 19:06:11 -04:00
parent 788d2bf8d1
commit f2465e0571
7 changed files with 45 additions and 13 deletions

View File

@@ -72,7 +72,9 @@ class Cli(object):
sshpass = None
if options.ask_pass:
sshpass = getpass.getpass(prompt="SSH password: ")
if options.ask_sudo_pass:
sudopass = getpass.getpass(prompt="sudo password: ")
if options.tree:
utils.prepare_writeable_dir(options.tree)
@@ -86,7 +88,8 @@ class Cli(object):
host_list=options.inventory, timeout=options.timeout,
remote_port=options.remote_port, forks=options.forks,
background=options.seconds, pattern=pattern,
callbacks=self.callbacks, sudo=options.sudo, verbose=True,
callbacks=self.callbacks, sudo=options.sudo,
sudo_pass=sudopass, verbose=True,
transport=options.connection, debug=options.debug
)
return (runner, runner.run())

View File

@@ -46,8 +46,11 @@ def main(args):
return 1
sshpass = None
sudopass = None
if options.ask_pass:
sshpass = getpass.getpass(prompt="SSH password: ")
if options.ask_sudo_pass:
sudopass = getpass.getpass(prompt="sudo password: ")
override_hosts = None
if options.override_hosts:
override_hosts = options.override_hosts.split(",")
@@ -66,7 +69,8 @@ def main(args):
forks=options.forks, debug=options.debug, verbose=True,
remote_pass=sshpass, remote_port=options.remote_port,
callbacks=playbook_cb, runner_callbacks=runner_cb, stats=stats,
timeout=options.timeout, transport=options.connection
timeout=options.timeout, transport=options.connection,
sudo_pass=sudopass
)
try: