dedupe the --rsh options in favor of user supplied (#38096)
This commit is contained in:
parent
6f2cb28bb9
commit
e10724fadb
1 changed files with 24 additions and 14 deletions
|
@ -462,20 +462,30 @@ def main():
|
||||||
module.fail_json(msg='either src or dest must be a localhost', rc=1)
|
module.fail_json(msg='either src or dest must be a localhost', rc=1)
|
||||||
|
|
||||||
if is_rsh_needed(source, dest):
|
if is_rsh_needed(source, dest):
|
||||||
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none']
|
|
||||||
if private_key is not None:
|
# https://github.com/ansible/ansible/issues/15907
|
||||||
ssh_cmd.extend(['-i', private_key])
|
has_rsh = False
|
||||||
# If the user specified a port value
|
for rsync_opt in rsync_opts:
|
||||||
# Note: The action plugin takes care of setting this to a port from
|
if '--rsh' in rsync_opt:
|
||||||
# inventory if the user didn't specify an explicit dest_port
|
has_rsh = True
|
||||||
if dest_port is not None:
|
break
|
||||||
ssh_cmd.extend(['-o', 'Port=%s' % dest_port])
|
|
||||||
if not verify_host:
|
# if the user has not supplied an --rsh option go ahead and add ours
|
||||||
ssh_cmd.extend(['-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null'])
|
if not has_rsh:
|
||||||
ssh_cmd_str = ' '.join(shlex_quote(arg) for arg in ssh_cmd)
|
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none']
|
||||||
if ssh_args:
|
if private_key is not None:
|
||||||
ssh_cmd_str += ' %s' % ssh_args
|
ssh_cmd.extend(['-i', private_key])
|
||||||
cmd.append('--rsh=%s' % ssh_cmd_str)
|
# 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
|
||||||
|
if dest_port is not None:
|
||||||
|
ssh_cmd.extend(['-o', 'Port=%s' % dest_port])
|
||||||
|
if not verify_host:
|
||||||
|
ssh_cmd.extend(['-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null'])
|
||||||
|
ssh_cmd_str = ' '.join(shlex_quote(arg) for arg in ssh_cmd)
|
||||||
|
if ssh_args:
|
||||||
|
ssh_cmd_str += ' %s' % ssh_args
|
||||||
|
cmd.append('--rsh=%s' % ssh_cmd_str)
|
||||||
|
|
||||||
if rsync_path:
|
if rsync_path:
|
||||||
cmd.append('--rsync-path=%s' % rsync_path)
|
cmd.append('--rsync-path=%s' % rsync_path)
|
||||||
|
|
Loading…
Reference in a new issue