From 1a7a779e88c968a330b2e4c25a4f7001bdb48fcd Mon Sep 17 00:00:00 2001 From: Sharif Olorin Date: Mon, 15 Jul 2013 17:11:24 +1000 Subject: [PATCH] Handle SSH failures when creating remote tmpdir Bail out if the SSH command fails rather than continuing with an empty tmp variable. --- lib/ansible/runner/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index d47ff8e72d..9d37d9fc39 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -719,7 +719,14 @@ class Runner(object): cmd += ' && echo %s' % basetmp result = self._low_level_exec_command(conn, cmd, None, sudoable=False) + if result['rc'] != 0: + raise errors.AnsibleError('could not create temporary directory: ' + 'SSH exited with return code %d' % result['rc']) rc = utils.last_non_blank_line(result['stdout']).strip() + '/' + # Catch any other failure conditions here; files should never be + # written directly to /. + if rc == '/': + raise errors.AnsibleError('refusing to use / as a temporary directory.') return rc