mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Add support for specifying sudo passwords to both ansible & playbook. Nopasswd sudo is no longer required.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user