From cd8c1c11087c6de3a20eb2c2978321f36a92cf9b Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Wed, 23 Aug 2017 18:28:44 -0400 Subject: [PATCH] Create persistent socket path using port and connection type (#28492) * Create persistent socket path using port and connection type * Use remote address, port, connection type and remote user to create a socket path. * Fix review comment --- bin/ansible-connection | 2 +- lib/ansible/plugins/connection/ssh.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/ansible-connection b/bin/ansible-connection index d2d10e71c2..31fd0ac0f7 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -295,7 +295,7 @@ def main(): sys.exit("FAIL: %s" % e) ssh = connection_loader.get('ssh', class_only=True) - cp = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user) + cp = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user, pc.connection) # create the persistent connection dir if need be and create the paths # which we will be using later diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 85669ff4ce..94e820b073 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -268,9 +268,11 @@ class Connection(ConnectionBase): sock.close() @staticmethod - def _create_control_path(host, port, user): + def _create_control_path(host, port, user, connection=None): '''Make a hash for the controlpath based on con attributes''' pstring = '%s-%s-%s' % (host, port, user) + if connection: + pstring += '-%s' % connection m = hashlib.sha1() m.update(to_bytes(pstring)) digest = m.hexdigest()