From e166f71fcc5f78ad2cd6739349a02892191b1233 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 29 Jan 2013 00:38:07 +0100 Subject: [PATCH] Get output before receiving return code Fixes hangs observed with large amounts of output, as it would get into a dead-lock. --- lib/ansible/runner/connection_plugins/paramiko_ssh.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection_plugins/paramiko_ssh.py b/lib/ansible/runner/connection_plugins/paramiko_ssh.py index 0f329bf7e5..813abfca6e 100644 --- a/lib/ansible/runner/connection_plugins/paramiko_ssh.py +++ b/lib/ansible/runner/connection_plugins/paramiko_ssh.py @@ -142,7 +142,9 @@ class Connection(object): except socket.timeout: raise errors.AnsibleError('ssh timed out waiting for sudo.\n' + sudo_output) - return (chan.recv_exit_status(), chan.makefile('wb', bufsize), chan.makefile('rb', bufsize), chan.makefile_stderr('rb', bufsize)) + stdout = ''.join(chan.makefile('rb', bufsize)) + stderr = ''.join(chan.makefile_stderr('rb', bufsize)) + return (chan.recv_exit_status(), '', stdout, stderr) def put_file(self, in_path, out_path): ''' transfer a file from local to remote '''