diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index f033553957..7213d9ffa4 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -305,7 +305,7 @@ class PlayBook(object): pattern=task.play.hosts, inventory=self.inventory, module_name=task.module_name, module_args=task.module_args, forks=self.forks, remote_pass=self.remote_pass, module_path=self.module_path, - timeout=self.timeout, remote_user=task.play.remote_user, + timeout=self.timeout, remote_user=task.remote_user, remote_port=task.play.remote_port, module_vars=task.module_vars, default_vars=task.default_vars, private_key_file=self.private_key_file, setup_cache=self.SETUP_CACHE, basedir=task.play.basedir, diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 67c2e1d3cd..93eb99b1db 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -28,7 +28,7 @@ class Task(object): 'notify', 'module_name', 'module_args', 'module_vars', 'default_vars', 'play', 'notified_by', 'tags', 'register', 'role_name', 'delegate_to', 'first_available_file', 'ignore_errors', - 'local_action', 'transport', 'sudo', 'sudo_user', 'sudo_pass', + 'local_action', 'transport', 'sudo', 'remote_user', 'sudo_user', 'sudo_pass', 'items_lookup_plugin', 'items_lookup_terms', 'environment', 'args', 'any_errors_fatal', 'changed_when', 'failed_when', 'always_run', 'delay', 'retries', 'until' ] @@ -37,7 +37,7 @@ class Task(object): VALID_KEYS = [ 'name', 'meta', 'action', 'only_if', 'async', 'poll', 'notify', 'first_available_file', 'include', 'tags', 'register', 'ignore_errors', - 'delegate_to', 'local_action', 'transport', 'sudo', 'sudo_user', + 'delegate_to', 'local_action', 'transport', 'remote_user', 'sudo', 'sudo_user', 'sudo_pass', 'when', 'connection', 'environment', 'args', 'any_errors_fatal', 'changed_when', 'failed_when', 'always_run', 'delay', 'retries', 'until' ] @@ -135,6 +135,8 @@ class Task(object): # can be hashes and lists, not just scalars self.args = ds.get('args', {}) + self.remote_user = ds.get('remote_user', play.playbook.remote_user) + if self.sudo: self.sudo_user = ds.get('sudo_user', play.sudo_user) self.sudo_pass = ds.get('sudo_pass', play.playbook.sudo_pass)