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:
parent
ad6c4a544e
commit
6908038036
1 changed files with 9 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue