1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

@ -467,7 +467,7 @@ def main():
if is_rsh_needed(source, dest):
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none']
if private_key is not None:
ssh_cmd.extend(['-i', private_key])
ssh_cmd.extend(['-i', os.path.expanduser(private_key) ])
# If the user specified a port value
# Note: The action plugin takes care of setting this to a port from
# inventory if the user didn't specify an explicit dest_port

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

View file

@ -23,4 +23,4 @@ asserts:
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'el6host:/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"

View file

@ -30,4 +30,4 @@ asserts:
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'el6host:/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"