Fix synchronize setting user variable

The user variable stores whether we need to set user@ in our connection
string.  It's now being used at the toplevel of the run() method so the
default needs to be calculated further up the stack

Fixes #24910
This commit is contained in:
Toshio Kuratomi 2017-05-25 11:25:13 -07:00
parent ad6c4a544e
commit 6908038036

View file

@ -310,17 +310,10 @@ class ActionModule(ActionBase):
if src is None or dest is None:
return dict(failed=True, msg="synchronize requires both src and dest parameters are set")
# Determine if we need a user@
user = None
if not dest_is_local:
# Private key handling
private_key = self._play_context.private_key_file
if private_key is not None:
private_key = os.path.expanduser(private_key)
_tmp_args['private_key'] = private_key
# Src and dest rsync "path" handling
# Determine if we need a user@
user = None
if boolean(_tmp_args.get('set_remote_user', 'yes')):
if use_delegate:
user = task_vars.get('ansible_delegated_vars', dict()).get('ansible_ssh_user', None)
@ -330,6 +323,13 @@ class ActionModule(ActionBase):
else:
user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user
# Private key handling
private_key = self._play_context.private_key_file
if private_key is not None:
private_key = os.path.expanduser(private_key)
_tmp_args['private_key'] = private_key
# use the mode to define src and dest's url
if _tmp_args.get('mode', 'push') == 'pull':
# src is a remote path: <user>@<host>, dest is a local path