Commit 1e7fd219 by James Cammarata

Fixing synchronize + delegate_to user bug

Fixes #12464
parent 3ffc2783
...@@ -101,7 +101,7 @@ class ActionModule(ActionBase): ...@@ -101,7 +101,7 @@ class ActionModule(ActionBase):
remote_transport = True remote_transport = True
try: try:
delegate_to = self._play_context.delegate_to delegate_to = self._task.delegate_to
except (AttributeError, KeyError): except (AttributeError, KeyError):
delegate_to = None delegate_to = None
...@@ -115,7 +115,7 @@ class ActionModule(ActionBase): ...@@ -115,7 +115,7 @@ class ActionModule(ActionBase):
# ansible's delegate_to mechanism to determine which host rsync is # ansible's delegate_to mechanism to determine which host rsync is
# running on so localhost could be a non-controller machine if # running on so localhost could be a non-controller machine if
# delegate_to is used) # delegate_to is used)
src_host = '127.0.0.1' src_host = '127.0.0.1'
dest_host = task_vars.get('ansible_ssh_host') or task_vars.get('inventory_hostname') dest_host = task_vars.get('ansible_ssh_host') or task_vars.get('inventory_hostname')
dest_is_local = dest_host in C.LOCALHOST dest_is_local = dest_host in C.LOCALHOST
...@@ -183,10 +183,11 @@ class ActionModule(ActionBase): ...@@ -183,10 +183,11 @@ class ActionModule(ActionBase):
user = None user = None
if boolean(self._task.args.get('set_remote_user', 'yes')): if boolean(self._task.args.get('set_remote_user', 'yes')):
if use_delegate: if use_delegate:
if 'hostvars' in task_vars and delegate_to in task_vars['hostvars']: user = task_vars.get('ansible_delegated_vars', dict()).get('ansible_ssh_user', None)
user = task_vars['hostvars'][delegate_to].get('ansible_ssh_user', None) if not user:
user = C.DEFAULT_REMOTE_USER
if not use_delegate or not user: else:
user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user
# use the mode to define src and dest's url # use the mode to define src and dest's url
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment