From 30c50020a1b6add9a461c94960dabfa4d73c08fd Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 10 Nov 2014 09:15:46 -0800 Subject: [PATCH] Better way to get the python_interpreter inventory variable --- lib/ansible/runner/__init__.py | 6 ++---- lib/ansible/runner/action_plugins/assemble.py | 2 +- lib/ansible/runner/action_plugins/copy.py | 4 ++-- lib/ansible/runner/action_plugins/fetch.py | 4 ++-- lib/ansible/runner/action_plugins/template.py | 2 +- lib/ansible/runner/action_plugins/unarchive.py | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 76412005441..6351e2aab87 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -1159,11 +1159,9 @@ class Runner(object): # ***************************************************** - def _remote_checksum(self, conn, tmp, path): + def _remote_checksum(self, conn, tmp, path, inject): ''' takes a remote checksum and returns 1 if no file ''' - inject = self.get_inject_vars(conn.host) - hostvars = HostVars(inject['combined_cache'], self.inventory, vault_password=self.vault_pass) - python_interp = hostvars[conn.host].get('ansible_python_interpreter', 'python') + python_interp = inject['hostvars'][inject['inventory_hostname']].get('ansible_python_interpreter', 'python') cmd = conn.shell.checksum(path, python_interp) data = self._low_level_exec_command(conn, cmd, tmp, sudoable=True) data2 = utils.last_non_blank_line(data['stdout']) diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index 9f5d450c2f8..b0a45c49706 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -109,7 +109,7 @@ class ActionModule(object): path = self._assemble_from_fragments(src, delimiter, _re) path_checksum = utils.checksum_s(path) - remote_checksum = self.runner._remote_checksum(conn, tmp, dest) + remote_checksum = self.runner._remote_checksum(conn, tmp, dest, inject) if path_checksum != remote_checksum: resultant = file(path).read() diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index 2b3d3871735..55524bca381 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -175,7 +175,7 @@ class ActionModule(object): dest_file = conn.shell.join_path(dest) # Attempt to get the remote checksum - remote_checksum = self.runner._remote_checksum(conn, tmp_path, dest_file) + remote_checksum = self.runner._remote_checksum(conn, tmp_path, dest_file, inject) if remote_checksum == '3': # The remote_checksum was executed on a directory. @@ -187,7 +187,7 @@ class ActionModule(object): else: # Append the relative source location to the destination and retry remote_checksum dest_file = conn.shell.join_path(dest, source_rel) - remote_checksum = self.runner._remote_checksum(conn, tmp_path, dest_file) + remote_checksum = self.runner._remote_checksum(conn, tmp_path, dest_file, inject) if remote_checksum != '1' and not force: # remote_file does not exist so continue to next iteration. diff --git a/lib/ansible/runner/action_plugins/fetch.py b/lib/ansible/runner/action_plugins/fetch.py index 825023a0bc9..030058498a3 100644 --- a/lib/ansible/runner/action_plugins/fetch.py +++ b/lib/ansible/runner/action_plugins/fetch.py @@ -73,7 +73,7 @@ class ActionModule(object): source = conn.shell.join_path(source) # calculate checksum for the remote file - remote_checksum = self.runner._remote_checksum(conn, tmp, source) + remote_checksum = self.runner._remote_checksum(conn, tmp, source, inject) # use slurp if sudo and permissions are lacking remote_data = None @@ -116,7 +116,7 @@ class ActionModule(object): # these don't fail because you may want to transfer a log file that possibly MAY exist # but keep going to fetch other log files if remote_checksum == '0': - result = dict(msg="unable to calculate the md5 sum of the remote file", file=source, changed=False) + result = dict(msg="unable to calculate the checksum of the remote file", file=source, changed=False) return ReturnData(conn=conn, result=result) if remote_checksum == '1': if fail_on_missing: diff --git a/lib/ansible/runner/action_plugins/template.py b/lib/ansible/runner/action_plugins/template.py index 2fe07c30394..75fd7ff5a6d 100644 --- a/lib/ansible/runner/action_plugins/template.py +++ b/lib/ansible/runner/action_plugins/template.py @@ -88,7 +88,7 @@ class ActionModule(object): return ReturnData(conn=conn, comm_ok=False, result=result) local_checksum = utils.checksum_s(resultant) - remote_checksum = self.runner._remote_checksum(conn, tmp, dest) + remote_checksum = self.runner._remote_checksum(conn, tmp, dest, inject) if local_checksum != remote_checksum: diff --git a/lib/ansible/runner/action_plugins/unarchive.py b/lib/ansible/runner/action_plugins/unarchive.py index 1f831e42074..f570a29d5c8 100644 --- a/lib/ansible/runner/action_plugins/unarchive.py +++ b/lib/ansible/runner/action_plugins/unarchive.py @@ -62,7 +62,7 @@ class ActionModule(object): else: source = utils.path_dwim(self.runner.basedir, source) - remote_checksum = self.runner._remote_checksum(conn, tmp, dest) + remote_checksum = self.runner._remote_checksum(conn, tmp, dest, inject) if remote_checksum != '3': result = dict(failed=True, msg="dest '%s' must be an existing dir" % dest) return ReturnData(conn=conn, result=result)