diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 349ba49de50..8c97988edc4 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -250,14 +250,13 @@ class ActionBase: self._display.debug("done with chmod call") return res - def _remote_checksum(self, tmp, path): + def _remote_checksum(self, tmp, path, all_vars): ''' Takes a remote checksum and returns 1 if no file ''' - # FIXME: figure out how this will work, probably pulled from the variable manager data - #python_interp = inject['hostvars'][inject['inventory_hostname']].get('ansible_python_interpreter', 'python') - python_interp = 'python' + python_interp = all_vars.get('ansible_python_interpreter', 'python') + cmd = self._connection._shell.checksum(path, python_interp) self._display.debug("calling _low_level_execute_command to get the remote checksum") data = self._low_level_execute_command(cmd, tmp, sudoable=True) diff --git a/lib/ansible/plugins/action/assemble.py b/lib/ansible/plugins/action/assemble.py index 454e28aa34e..e02f8663956 100644 --- a/lib/ansible/plugins/action/assemble.py +++ b/lib/ansible/plugins/action/assemble.py @@ -108,7 +108,7 @@ class ActionModule(ActionBase): path_checksum = checksum_s(path) dest = self._remote_expand_user(dest, tmp) - remote_checksum = self._remote_checksum(tmp, dest) + remote_checksum = self._remote_checksum(tmp, dest, all_vars=task_vars) if path_checksum != remote_checksum: resultant = file(path).read() diff --git a/lib/ansible/plugins/action/copy.py b/lib/ansible/plugins/action/copy.py index 34a426f5e27..f70f67c1ba6 100644 --- a/lib/ansible/plugins/action/copy.py +++ b/lib/ansible/plugins/action/copy.py @@ -145,7 +145,7 @@ class ActionModule(ActionBase): dest_file = self._connection._shell.join_path(dest) # Attempt to get the remote checksum - remote_checksum = self._remote_checksum(tmp, dest_file) + remote_checksum = self._remote_checksum(tmp, dest_file, all_vars=task_vars) if remote_checksum == '3': # The remote_checksum was executed on a directory. @@ -156,7 +156,7 @@ class ActionModule(ActionBase): else: # Append the relative source location to the destination and retry remote_checksum dest_file = self._connection._shell.join_path(dest, source_rel) - remote_checksum = self._remote_checksum(tmp, dest_file) + remote_checksum = self._remote_checksum(tmp, dest_file, all_vars=task_vars) if remote_checksum != '1' and not force: # remote_file does not exist so continue to next iteration. diff --git a/lib/ansible/plugins/action/fetch.py b/lib/ansible/plugins/action/fetch.py index 81edf65ef14..8c9a2ed16d1 100644 --- a/lib/ansible/plugins/action/fetch.py +++ b/lib/ansible/plugins/action/fetch.py @@ -55,7 +55,7 @@ class ActionModule(ActionBase): source = self._remote_expand_user(source, tmp) # calculate checksum for the remote file - remote_checksum = self._remote_checksum(tmp, source) + remote_checksum = self._remote_checksum(tmp, source, all_vars=task_vars) # use slurp if sudo and permissions are lacking remote_data = None diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index 358d7d31648..095a90f90e3 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -31,8 +31,8 @@ class ActionModule(ActionBase): TRANSFERS_FILES = True - def get_checksum(self, tmp, dest, try_directory=False, source=None): - remote_checksum = self._remote_checksum(tmp, dest) + def get_checksum(self, tmp, dest, all_vars, try_directory=False, source=None): + remote_checksum = self._remote_checksum(tmp, dest, all_vars=all_vars) if remote_checksum in ('0', '2', '3', '4'): # Note: 1 means the file is not present which is fine; template @@ -40,7 +40,7 @@ class ActionModule(ActionBase): if try_directory and remote_checksum == '3' and source: base = os.path.basename(source) dest = os.path.join(dest, base) - remote_checksum = self.get_checksum(tmp, dest, try_directory=False) + remote_checksum = self.get_checksum(tmp, dest, all_vars=all_vars, try_directory=False) if remote_checksum not in ('0', '2', '3', '4'): return remote_checksum @@ -124,7 +124,7 @@ class ActionModule(ActionBase): return dict(failed=True, msg=type(e).__name__ + ": " + str(e)) local_checksum = checksum_s(resultant) - remote_checksum = self.get_checksum(tmp, dest, not directory_prepended, source=source) + remote_checksum = self.get_checksum(tmp, dest, task_vars, not directory_prepended, source=source) if isinstance(remote_checksum, dict): # Error from remote_checksum is a dict. Valid return is a str return remote_checksum diff --git a/lib/ansible/plugins/action/unarchive.py b/lib/ansible/plugins/action/unarchive.py index 63ab6c549cc..d2b158021db 100644 --- a/lib/ansible/plugins/action/unarchive.py +++ b/lib/ansible/plugins/action/unarchive.py @@ -66,7 +66,7 @@ class ActionModule(ActionBase): else: source = self._loader.path_dwim(source) - remote_checksum = self._remote_checksum(tmp, dest) + remote_checksum = self._remote_checksum(tmp, dest, all_vars=task_vars) if remote_checksum != '3': return dict(failed=True, msg="dest '%s' must be an existing dir" % dest) elif remote_checksum == '4':