Remove tmp as a parameter to the connection plugins

There doesn't appear to be anything that actually uses tmp_path in the
connection plugins so we don't need to pass that in to exec_command.
That change also means that we don't need to pass tmp_path around in
many places in the action plugins any more.  there may be more cleanup
that can be done there as well (the action plugin's public run() method
takes tmp as a keyword arg but that may not be necessary).

As a sideeffect of this patch, some potential problems with chmod and
the patch, assemble, copy, and template modules has been fixed (those
modules called _remote_chmod() with the wrong order for their
parameters.  Removing the tmp parameter fixed them.)
This commit is contained in:
Toshio Kuratomi 2015-09-24 13:29:36 -07:00
commit a1428d6bed
24 changed files with 81 additions and 73 deletions

View file

@ -31,8 +31,8 @@ class ActionModule(ActionBase):
TRANSFERS_FILES = True
def get_checksum(self, tmp, dest, all_vars, try_directory=False, source=None):
remote_checksum = self._remote_checksum(tmp, dest, all_vars=all_vars)
def get_checksum(self, dest, all_vars, try_directory=False, source=None):
remote_checksum = self._remote_checksum(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, all_vars=all_vars, try_directory=False)
remote_checksum = self.get_checksum(dest, all_vars=all_vars, try_directory=False)
if remote_checksum not in ('0', '2', '3', '4'):
return remote_checksum
@ -74,7 +74,7 @@ class ActionModule(ActionBase):
source = self._loader.path_dwim_relative(self._loader.get_basedir(), 'templates', source)
# Expand any user home dir specification
dest = self._remote_expand_user(dest, tmp)
dest = self._remote_expand_user(dest)
directory_prepended = False
if dest.endswith(os.sep):
@ -128,7 +128,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, task_vars, not directory_prepended, source=source)
remote_checksum = self.get_checksum(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
@ -141,14 +141,14 @@ class ActionModule(ActionBase):
# if showing diffs, we need to get the remote value
if self._play_context.diff:
diff = self._get_diff_data(tmp, dest, resultant, task_vars, source_file=False)
diff = self._get_diff_data(dest, resultant, task_vars, source_file=False)
if not self._play_context.check_mode: # do actual work thorugh copy
xfered = self._transfer_data(self._connection._shell.join_path(tmp, 'source'), resultant)
# fix file permissions when the copy is done as a different user
if self._play_context.become and self._play_context.become_user != 'root':
self._remote_chmod('a+r', xfered, tmp)
self._remote_chmod('a+r', xfered)
# run the copy module
new_module_args.update(