From 6bf5d664dc5af64098db97bc96b9d62525b6b38a Mon Sep 17 00:00:00 2001 From: dparalen Date: Fri, 20 Dec 2013 13:22:17 +0100 Subject: [PATCH] allow per-host sudo operation --- lib/ansible/runner/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 3318bcba2b..b2278e5d7f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -604,8 +604,16 @@ class Runner(object): actual_pass = inject.get('ansible_ssh_pass', self.remote_pass) actual_transport = inject.get('ansible_connection', self.transport) actual_private_key_file = inject.get('ansible_ssh_private_key_file', self.private_key_file) + self.sudo = utils.boolean(inject.get('ansible_sudo', self.sudo)) + self.sudo_user = inject.get('ansible_sudo_user', self.sudo_user) self.sudo_pass = inject.get('ansible_sudo_pass', self.sudo_pass) + # select default root user in case self.sudo requested + # but no user specified; happens e.g. in host vars when + # just ansible_sudo=True is specified + if self.sudo and self.sudo_user is None: + self.sudo_user = 'root' + if actual_private_key_file is not None: actual_private_key_file = os.path.expanduser(actual_private_key_file)