summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/ansible-connection2
-rw-r--r--lib/ansible/plugins/connection/persistent.py20
2 files changed, 17 insertions, 5 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection
index 8e9114817c..fde1883e1f 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -249,7 +249,7 @@ class Server():
break
time.sleep(1)
timeout -= 1
- return (0, self.socket_path, '')
+ return 0, b'\n#SOCKET_PATH#: %s\n' % self.socket_path, ''
def communicate(sock, data):
diff --git a/lib/ansible/plugins/connection/persistent.py b/lib/ansible/plugins/connection/persistent.py
index 9b0df90cbb..7c7aa53208 100644
--- a/lib/ansible/plugins/connection/persistent.py
+++ b/lib/ansible/plugins/connection/persistent.py
@@ -66,11 +66,12 @@ class Connection(ConnectionBase):
(stdout, stderr) = p.communicate()
stdin.close()
- return (p.returncode, stdout, stderr)
+ return (p, stdout, stderr)
def exec_command(self, cmd, in_data=None, sudoable=True):
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
- return self._do_it('EXEC: ' + cmd)
+ p, out, err = self._do_it('EXEC: ' + cmd)
+ return p.returncode, out, err
def put_file(self, in_path, out_path):
super(Connection, self).put_file(in_path, out_path)
@@ -90,5 +91,16 @@ class Connection(ConnectionBase):
socket path exists. If the path exists (or the timeout has expired),
returns the socket path.
"""
- rc, out, err = self._do_it('RUN:')
- return to_text(out, errors='surrogate_or_strict')
+ p, out, err = self._do_it('RUN:')
+ while True:
+ out = out.strip()
+ if out == b'':
+ # EOF file found
+ return None
+ elif out.startswith(b'#SOCKET_PATH#'):
+ break
+ else:
+ out = p.stdout.readline()
+
+ socket_path = out.split(b'#SOCKET_PATH#: ', 1)[1]
+ return to_text(socket_path, errors='surrogate_or_strict')