From 4dfd86d8478d36f1e774c8770a0a8eb610d9ffb1 Mon Sep 17 00:00:00 2001 From: James Keener Date: Wed, 3 Dec 2014 16:28:55 -0500 Subject: [PATCH] Issue-9704 Better handling of missing python When they python interpreter is set incorrectly for the machine the file is being checked for (e.g. for the local or the remote), the error manifests as a readability or directory missing error which can be very misleading. --- lib/ansible/runner/action_plugins/copy.py | 4 ++++ lib/ansible/runner/action_plugins/fetch.py | 2 +- lib/ansible/runner/action_plugins/unarchive.py | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index b1804489882..bb579e48a8e 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -192,6 +192,10 @@ class ActionModule(object): dest_file = conn.shell.join_path(dest, source_rel) remote_checksum = self.runner._remote_checksum(conn, tmp_path, dest_file, inject) + if remote_checksum == '4': + result = dict(msg="python isn't present on the system. Unable to compute checksum", failed=True) + return ReturnData(conn=conn, result=result) + if remote_checksum != '1' and not force: # remote_file does not exist so continue to next iteration. continue diff --git a/lib/ansible/runner/action_plugins/fetch.py b/lib/ansible/runner/action_plugins/fetch.py index 2fb6631536c..3fa748ccbd1 100644 --- a/lib/ansible/runner/action_plugins/fetch.py +++ b/lib/ansible/runner/action_plugins/fetch.py @@ -129,7 +129,7 @@ class ActionModule(object): elif remote_checksum == '3': result = dict(msg="remote file is a directory, fetch cannot work on directories", file=source, changed=False) elif remote_checksum == '4': - result = dict(msg="python isn't present on the remote system. Unable to fetch file", file=source, changed=False) + result = dict(msg="python isn't present on the system. Unable to compute checksum", file=source, changed=False) return ReturnData(conn=conn, result=result) # calculate checksum for the local file diff --git a/lib/ansible/runner/action_plugins/unarchive.py b/lib/ansible/runner/action_plugins/unarchive.py index b528a25a397..cfcaf454bd1 100644 --- a/lib/ansible/runner/action_plugins/unarchive.py +++ b/lib/ansible/runner/action_plugins/unarchive.py @@ -83,6 +83,9 @@ class ActionModule(object): source = utils.path_dwim(self.runner.basedir, source) remote_checksum = self.runner._remote_checksum(conn, tmp, dest, inject) + if remote_checksum == '4': + result = dict(failed=True, msg="python isn't present on the system. Unable to compute checksum") + return ReturnData(conn=conn, result=result) if remote_checksum != '3': result = dict(failed=True, msg="dest '%s' must be an existing dir" % dest) return ReturnData(conn=conn, result=result)