From cbf54f214c2f4dbe899e2b515165b7ba2d66f092 Mon Sep 17 00:00:00 2001 From: pneerincx Date: Thu, 10 Dec 2020 20:52:34 +0100 Subject: [PATCH 1/2] Added option to allow SSH connection multiplixing as opposed to hard-coded disabling it. Fixes bug #24365. --- plugins/modules/synchronize.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/modules/synchronize.py b/plugins/modules/synchronize.py index c2fc592..080895a 100644 --- a/plugins/modules/synchronize.py +++ b/plugins/modules/synchronize.py @@ -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`. type: bool 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: description: - Specify additional rsync options by passing in an array. @@ -392,6 +402,7 @@ def main(): rsync_timeout=dict(type='int', default=0), rsync_opts=dict(type='list', default=[]), ssh_args=dict(type='str'), + ssh_connection_multiplexing=dict(type='bool', default=False), partial=dict(type='bool', default=False), verify_host=dict(type='bool', default=False), mode=dict(type='str', default='push', choices=['pull', 'push']), @@ -432,6 +443,7 @@ def main(): group = module.params['group'] rsync_opts = module.params['rsync_opts'] ssh_args = module.params['ssh_args'] + ssh_connection_multiplexing = module.params['ssh_connection_multiplexing'] verify_host = module.params['verify_host'] 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 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: ssh_cmd.extend(['-i', private_key]) # If the user specified a port value From 665f84d996d5b8abd37f085e034d9bd7f4295ce7 Mon Sep 17 00:00:00 2001 From: pneerincx Date: Fri, 11 Dec 2020 15:16:03 +0100 Subject: [PATCH 2/2] Removed trailing whitespace to satisfy PEP8 rule W291. --- plugins/modules/synchronize.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/synchronize.py b/plugins/modules/synchronize.py index 080895a..9e0a5c9 100644 --- a/plugins/modules/synchronize.py +++ b/plugins/modules/synchronize.py @@ -147,8 +147,8 @@ options: 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). + 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: