summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPeter Sprygada <privateip@users.noreply.github.com>2017-02-09 14:05:54 -0500
committerGitHub <noreply@github.com>2017-02-09 14:05:54 -0500
commit138051540ea2ebd9c7419805128edba920bcfc70 (patch)
treed3e29aa637ce0b8339120804c0298d0e4e10afc9 /bin
parent25cb281b9b11212ab84cfb4677f7477c0ef5f096 (diff)
downloadansible-138051540ea2ebd9c7419805128edba920bcfc70.tar.gz
updates the code path for network modules (#21193)
* replaces persistent connection digest with _create_control_path() * adds _ansible_socket to _legal_inputs in basic.py * adds connection_user to play_context * maps remote_user to connection_user when connection is local * maps ansible_socket in task_vars to module_args _ansible_socket if exists
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ansible-connection14
1 files changed, 5 insertions, 9 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection
index 143070396c..1eecccd179 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -29,7 +29,6 @@ except Exception:
pass
import fcntl
-import hashlib
import os
import shlex
import signal
@@ -119,6 +118,8 @@ class Server():
self._start_time = datetime.datetime.now()
+ self.log("setup connection %s" % self.play_context.connection)
+
self.conn = connection_loader.get(play_context.connection, play_context, sys.stdin)
self.conn._connect()
if not self.conn.connected:
@@ -259,20 +260,15 @@ def main():
display.verbosity = pc.verbosity
- # here we create a hash to use later when creating the socket file,
- # so we can hide the info about the target host/user/etc.
- m = hashlib.sha256()
- for attr in ('connection', 'remote_addr', 'port', 'remote_user'):
- val = getattr(pc, attr, None)
- if val:
- m.update(to_bytes(val))
+ ssh = connection_loader.get('ssh', class_only=True)
+ m = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user)
# create the persistent connection dir if need be and create the paths
# which we will be using later
tmp_path = unfrackpath("$HOME/.ansible/pc")
makedirs_safe(tmp_path)
lk_path = unfrackpath("%s/.ansible_pc_lock" % tmp_path)
- sf_path = unfrackpath("%s/conn-%s" % (tmp_path, m.hexdigest()[0:12]))
+ sf_path = unfrackpath(m % dict(directory=tmp_path))
# if the socket file doesn't exist, spin up the daemon process
lock_fd = os.open(lk_path, os.O_RDWR|os.O_CREAT, 0o600)