Use ansible_python_interpreter value for remote checksums
Fixes #11968 Fixes #11969
This commit is contained in:
parent
7a51836530
commit
4836641683
6 changed files with 12 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue