From 569d377183662c52f5ca4d6967c72d44ab0ad48a Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Thu, 9 Aug 2012 21:47:09 -0700 Subject: [PATCH] Wrap paramiko open_session() call in try/except Ran across non-unix host where the call to paramiko's open_session() in exec_command() would throw a EOFError exception. This change wraps the block in a try/except. --- lib/ansible/runner/connection/paramiko_ssh.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection/paramiko_ssh.py b/lib/ansible/runner/connection/paramiko_ssh.py index 4a00a76d11..b38d105dd4 100644 --- a/lib/ansible/runner/connection/paramiko_ssh.py +++ b/lib/ansible/runner/connection/paramiko_ssh.py @@ -81,7 +81,13 @@ class ParamikoConnection(object): ''' run a command on the remote host ''' bufsize = 4096 - chan = self.ssh.get_transport().open_session() + try: + chan = self.ssh.get_transport().open_session() + except Exception, e: + msg = "Failed to open session" + if len(str(e)) > 0: + msg += ": %s" % str(e) + raise errors.AnsibleConnectionFailed(msg) chan.get_pty() if not self.runner.sudo or not sudoable: