Skip to content

Instantly share code, notes, and snippets.

diff --git a/lib/ansible/plugins/connections/ssh.py b/lib/ansible/plugins/connections/ssh.py
index f7b17c5..5a6a732 100644
--- a/lib/ansible/plugins/connections/ssh.py
+++ b/lib/ansible/plugins/connections/ssh.py
@@ -360,6 +360,14 @@ class Connection(ConnectionBase):
display_cmd = map(pipes.quote, cmd[:-1]) + [cmd[-1]]
self._display.vvv('SSH: EXEC {0}'.format(' '.join(display_cmd)), host=self.host)
+ # We begin by acquiring the connection lock, so that if ssh issues a
+ # host key verification prompt, output from other connections doesn't
diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index d3a8877..debe36b 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -457,12 +457,17 @@ class Connection(ConnectionBase):
tmp_stdout = tmp_stderr = ''
# If we see a privilege escalation prompt, we send the password.
+ # (If we're expecting a prompt but the escalation succeeds, we
+ # didn't need the password and can carry on regardless.)
diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index 73689aa..77b1f8d 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -404,6 +404,8 @@ class Connection(ConnectionBase):
if not rfd:
if state <= states.index('awaiting_escalation'):
+ if p.poll() is not None:
+ break