Added option to allow SSH connection multiplixing as opposed to hard-coded disabling it. Fixes bug #24365.

This commit is contained in:
pneerincx 2020-12-10 20:52:34 +01:00
parent 6343dbdcff
commit cbf54f214c

View file

@ -141,6 +141,16 @@ options:
- Use the ssh_args specified in ansible.cfg. Setting this to `yes` will also make `synchronize` use `ansible_ssh_common_args`. - Use the ssh_args specified in ansible.cfg. Setting this to `yes` will also make `synchronize` use `ansible_ssh_common_args`.
type: bool type: bool
default: no default: no
ssh_connection_multiplexing:
description:
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
This is accomplished by setting the SSH C(ControlSocket) to C(none).
- Set this option to C(yes) to allow multiplexing and reduce SSH connection overhead.
- Note that simply setting this option to C(yes) is not enough;
You must also configure SSH connection multiplexing in your SSH client config by setting values for C(ControlMaster),
C(ControlPersist) and C(ControlPath).
type: bool
default: no
rsync_opts: rsync_opts:
description: description:
- Specify additional rsync options by passing in an array. - Specify additional rsync options by passing in an array.
@ -392,6 +402,7 @@ def main():
rsync_timeout=dict(type='int', default=0), rsync_timeout=dict(type='int', default=0),
rsync_opts=dict(type='list', default=[]), rsync_opts=dict(type='list', default=[]),
ssh_args=dict(type='str'), ssh_args=dict(type='str'),
ssh_connection_multiplexing=dict(type='bool', default=False),
partial=dict(type='bool', default=False), partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False), verify_host=dict(type='bool', default=False),
mode=dict(type='str', default='push', choices=['pull', 'push']), mode=dict(type='str', default='push', choices=['pull', 'push']),
@ -432,6 +443,7 @@ def main():
group = module.params['group'] group = module.params['group']
rsync_opts = module.params['rsync_opts'] rsync_opts = module.params['rsync_opts']
ssh_args = module.params['ssh_args'] ssh_args = module.params['ssh_args']
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
verify_host = module.params['verify_host'] verify_host = module.params['verify_host']
link_dest = module.params['link_dest'] link_dest = module.params['link_dest']
@ -507,7 +519,9 @@ def main():
# if the user has not supplied an --rsh option go ahead and add ours # if the user has not supplied an --rsh option go ahead and add ours
if not has_rsh: if not has_rsh:
ssh_cmd = [module.get_bin_path('ssh', required=True), '-S', 'none'] ssh_cmd = [module.get_bin_path('ssh', required=True)]
if not ssh_connection_multiplexing:
ssh_cmd.extend(['-S', 'none'])
if private_key is not None: if private_key is not None:
ssh_cmd.extend(['-i', private_key]) ssh_cmd.extend(['-i', private_key])
# If the user specified a port value # If the user specified a port value