synchronize: Use private_key and ssh_user with delegate_to (Fixes #16215) (#21686)

This commit is contained in:
Nicolas Porcel 2017-08-25 03:09:15 +02:00 committed by Martin Krizek
parent 7d8a4b13a5
commit ba420c47cd
4 changed files with 5 additions and 4 deletions

View file

@ -316,6 +316,8 @@ class ActionModule(ActionBase):
if boolean(_tmp_args.get('set_remote_user', 'yes'), strict=False):
if use_delegate:
user = task_vars.get('ansible_delegated_vars', dict()).get('ansible_ssh_user', None)
if not user:
user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user
if not user:
user = C.DEFAULT_REMOTE_USER
@ -326,7 +328,6 @@ class ActionModule(ActionBase):
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