From f9bdfde614a2c9a8232db9d355626345fad17f4b Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Thu, 9 Aug 2012 21:45:00 -0700 Subject: [PATCH 1/2] Fixes for runner and raw module runner should not try to create or remove tmp paths when using the raw module. --- lib/ansible/runner/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index ec71af5fe4..0fec2e381d 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -568,7 +568,9 @@ class Runner(object): module_name = utils.template(self.module_name, inject) - tmp = self._make_tmp_path(conn) + tmp = '' + if self.module_name != 'raw': + tmp = self._make_tmp_path(conn) result = None handler = getattr(self, "_execute_%s" % self.module_name, None) @@ -595,7 +597,8 @@ class Runner(object): del result.result['daisychain'] - self._delete_remote_files(conn, tmp) + if self.module_name != 'raw': + self._delete_remote_files(conn, tmp) conn.close() if not result.comm_ok: From 569d377183662c52f5ca4d6967c72d44ab0ad48a Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Thu, 9 Aug 2012 21:47:09 -0700 Subject: [PATCH 2/2] 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: