From 4088243debb24388b4e8952756fb1b13a4e39598 Mon Sep 17 00:00:00 2001 From: Paul Durivage Date: Tue, 17 Dec 2013 16:26:58 -0600 Subject: Proposing fix for Issue #4324; adding support for su in connection plugins ssh, ssh_alt Fixes for ssh_alt support, adding in references to in_data where appropriate --- bin/ansible | 33 ++++++++++++++++++++++++--------- bin/ansible-playbook | 11 +++++++++-- 2 files changed, 33 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/ansible b/bin/ansible index 3d4cb07ad9..84776c5a6d 100755 --- a/bin/ansible +++ b/bin/ansible @@ -96,31 +96,46 @@ class Cli(object): sshpass = None sudopass = None + su_pass = None options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS # Never ask for an SSH password when we run with local connection if options.connection == "local": options.ask_pass = False options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS - (sshpass, sudopass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass) - if options.sudo_user or options.ask_sudo_pass: + options.ask_su_pass = options.ask_su_pass or C.DEFAULT_ASK_SU_PASS + (sshpass, sudopass, su_pass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass, ask_su_pass=options.ask_su_pass) + if options.su_user or options.ask_su_pass: + options.su = True + elif options.sudo_user or options.ask_sudo_pass: options.sudo = True options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER + options.su_user = options.su_user or C.DEFAULT_SU_USER if options.tree: utils.prepare_writeable_dir(options.tree) + runner = Runner( - module_name=options.module_name, module_path=options.module_path, + module_name=options.module_name, + module_path=options.module_path, module_args=options.module_args, - remote_user=options.remote_user, remote_pass=sshpass, - inventory=inventory_manager, timeout=options.timeout, + remote_user=options.remote_user, + remote_pass=sshpass, + inventory=inventory_manager, + timeout=options.timeout, private_key_file=options.private_key_file, forks=options.forks, pattern=pattern, - callbacks=self.callbacks, sudo=options.sudo, - sudo_pass=sudopass,sudo_user=options.sudo_user, - transport=options.connection, subset=options.subset, + callbacks=self.callbacks, + sudo=options.sudo, + sudo_pass=sudopass, + sudo_user=options.sudo_user, + transport=options.connection, + subset=options.subset, check=options.check, - diff=options.check + diff=options.check, + su=options.su, + su_pass=su_pass, + su_user=options.su_user ) if options.seconds: diff --git a/bin/ansible-playbook b/bin/ansible-playbook index c0db66993c..4f8934ebb5 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -90,14 +90,18 @@ def main(args): sshpass = None sudopass = None + su_pass = None if not options.listhosts and not options.syntax and not options.listtasks: options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS # Never ask for an SSH password when we run with local connection if options.connection == "local": options.ask_pass = False options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS - (sshpass, sudopass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass) + options.ask_su_pass = options.ask_su_pass or C.DEFAULT_ASK_SU_PASS + (sshpass, sudopass, su_pass) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass, ask_su_pass=options.ask_su_pass) options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER + options.su_user = options.su_user or C.DEFAULT_SU_USER + extra_vars = {} for extra_vars_opt in options.extra_vars: @@ -156,7 +160,10 @@ def main(args): only_tags=only_tags, skip_tags=skip_tags, check=options.check, - diff=options.diff + diff=options.diff, + su=options.su, + su_pass=su_pass, + su_user=options.su_user ) if options.listhosts or options.listtasks or options.syntax: -- cgit v1.2.1