From 9700d9c04fc492fb4987f9d458009e84e8bffacf Mon Sep 17 00:00:00 2001
From: Abhijit Menon-Sen <ams@2ndQuadrant.com>
Date: Wed, 23 Sep 2015 22:32:15 +0530
Subject: [PATCH 1/2] Fix typo in checking select results

It's possible for more than one fd to be set, so 'elif' is obviously not
the right thing to use.
---
 lib/ansible/plugins/connection/ssh.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index f8fca1bd294..cfc51619e2d 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -460,14 +460,14 @@ class Connection(ConnectionBase):
             # Read whatever output is available on stdout and stderr, and stop
             # listening to the pipe if it's been closed.
 
-            elif p.stdout in rfd:
+            if p.stdout in rfd:
                 chunk = p.stdout.read()
                 if chunk == '':
                     rpipes.remove(p.stdout)
                 tmp_stdout += chunk
                 #self._display.debug("stdout chunk (state=%s):\n>>>%s<<<\n" % (state, chunk))
 
-            elif p.stderr in rfd:
+            if p.stderr in rfd:
                 chunk = p.stderr.read()
                 if chunk == '':
                     rpipes.remove(p.stderr)

From 40f608a377cbd7bbd962c055f8961e6ff076b0c4 Mon Sep 17 00:00:00 2001
From: Abhijit Menon-Sen <ams@2ndQuadrant.com>
Date: Wed, 23 Sep 2015 22:35:14 +0530
Subject: [PATCH 2/2] A bit more debugging output

We used to display input chunks earlier anyway, so this isn't making
things more verbose.
---
 lib/ansible/plugins/connection/ssh.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index cfc51619e2d..3add0298b2a 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -465,14 +465,14 @@ class Connection(ConnectionBase):
                 if chunk == '':
                     rpipes.remove(p.stdout)
                 tmp_stdout += chunk
-                #self._display.debug("stdout chunk (state=%s):\n>>>%s<<<\n" % (state, chunk))
+                self._display.debug("stdout chunk (state=%s):\n>>>%s<<<\n" % (state, chunk))
 
             if p.stderr in rfd:
                 chunk = p.stderr.read()
                 if chunk == '':
                     rpipes.remove(p.stderr)
                 tmp_stderr += chunk
-                #self._display.debug("stderr chunk (state=%s):\n>>>%s<<<\n" % (state, chunk))
+                self._display.debug("stderr chunk (state=%s):\n>>>%s<<<\n" % (state, chunk))
 
             # We examine the output line-by-line until we have negotiated any
             # privilege escalation prompt and subsequent success/error message.
@@ -578,7 +578,7 @@ class Connection(ConnectionBase):
         just hang forever waiting for more commands.)
         '''
 
-        self._display.debug('Sending initial data (%d bytes)' % len(in_data))
+        self._display.debug('Sending initial data')
 
         try:
             fh.write(in_data)
@@ -586,6 +586,8 @@ class Connection(ConnectionBase):
         except (OSError, IOError):
             raise AnsibleConnectionFailure('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
 
+        self._display.debug('Sent initial data (%d bytes)' % len(in_data))
+
     # This is a separate method because we need to do the same thing for stdout
     # and stderr.