Better way to get the python_interpreter inventory variable

pull/9534/head
Toshio Kuratomi 10 years ago
parent d32e1adb1b
commit 30c50020a1

@ -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'])

@ -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()

@ -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.

@ -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:

@ -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:

@ -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)

Loading…
Cancel
Save