Skip to content

Commit

Permalink
Create persistent socket path using port and connection type (ansible…
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
ganeshrn authored and bcoca committed Aug 23, 2017
1 parent 9407a17 commit cd8c1c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/ansible-connection
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/ansible/plugins/connection/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ def transport_test(self, connect_timeout):
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()
Expand Down

0 comments on commit cd8c1c1

Please sign in to comment.