1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

First bit of fixing temporary to have one source of truth (#35747)

* First bit of fixing temporary to have one source of truth

* Fix pep8

* Remove explicit make_tmp_path() in copy

The copy action plugin sets TRANSFER_FILES=True so it does not need to
set the temporary directory explicitly; the base class's run() method
will do that for us.

* Fix for calling a module's run when a shell has already created a temp path.

* Remember to inform the rest of the world when tempdir is removed

* New strategy for how to warn on passing tmp

Now we just warn when calling the parent class run() early.  If the
module does a late call to the parent run() and doesn't make use of the
temporary directory, then we don't check for the possibility that the
user mistakenly is sending tmp in.  If we truly deprecate this (rather
than ignoring it forever) then we might want to switch back to checking
for someone passing a value in as tmp.

* Remove tmp parameter from _execute_module as well

* Port all action plugins to not send tmp explicitly

This is now handled inside of _execute_module via the
_connection._shell.tempdir attribute.

Also update warnings and docs to tell people to set the attribute
instead of using _execute_module's tmp parameter.

* Always set local tempdir variable
This commit is contained in:
Toshio Kuratomi 2018-02-07 15:11:36 -08:00 committed by Matt Davis
parent 7225839bef
commit 71f46d69d6
82 changed files with 210 additions and 117 deletions

View file

@ -66,9 +66,9 @@ class ActionBase(with_metaclass(ABCMeta, object)):
tasks. Everything else in this base class is a helper method for the tasks. Everything else in this base class is a helper method for the
action plugin to do that. action plugin to do that.
:kwarg tmp: Temporary directory. Sometimes an action plugin sets up :kwarg tmp: Deprecated parameter. This is no longer used. An action plugin that calls
a temporary directory and then calls another module. This parameter another one and wants to use the same remote tmp for both should set
allows us to reuse the same directory for both. self._connection._shell.tempdir rather than this parameter.
:kwarg task_vars: The variables (host vars, group vars, config vars, :kwarg task_vars: The variables (host vars, group vars, config vars,
etc) associated with this task. etc) associated with this task.
:returns: dictionary of results from the module :returns: dictionary of results from the module
@ -80,6 +80,12 @@ class ActionBase(with_metaclass(ABCMeta, object)):
result = {} result = {}
if tmp is not None:
result['warning'] = ['ActionModule.run() no longer honors the tmp parameter. Action'
' plugins should set self._connection._shell.tempdir to share'
' the tempdir']
del tmp
if self._task.async_val and not self._supports_async: if self._task.async_val and not self._supports_async:
raise AnsibleActionFail('async is not supported for this task.') raise AnsibleActionFail('async is not supported for this task.')
elif self._play_context.check_mode and not self._supports_check_mode: elif self._play_context.check_mode and not self._supports_check_mode:
@ -87,10 +93,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
elif self._task.async_val and self._play_context.check_mode: elif self._task.async_val and self._play_context.check_mode:
raise AnsibleActionFail('check mode and async cannot be used on same task.') raise AnsibleActionFail('check mode and async cannot be used on same task.')
if not tmp and self._early_needs_tmp_path(): if self._connection._shell.tempdir is None and self._early_needs_tmp_path():
self._make_tmp_path() self._make_tmp_path()
else:
self._connection._shell.tempdir = tmp
return result return result
@ -311,6 +315,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
if tmp_rm_data.get('rc', 0) != 0: if tmp_rm_data.get('rc', 0) != 0:
display.warning('Error deleting remote temporary files (rc: %s, stderr: %s})' display.warning('Error deleting remote temporary files (rc: %s, stderr: %s})'
% (tmp_rm_res.get('rc'), tmp_rm_res.get('stderr', 'No error string available.'))) % (tmp_rm_res.get('rc'), tmp_rm_res.get('stderr', 'No error string available.')))
else:
self._connection._shell.tempdir = None
def _transfer_file(self, local_path, remote_path): def _transfer_file(self, local_path, remote_path):
self._connection.put_file(local_path, remote_path) self._connection.put_file(local_path, remote_path)
@ -485,13 +491,19 @@ class ActionBase(with_metaclass(ABCMeta, object)):
''' '''
Get information from remote file. Get information from remote file.
''' '''
if tmp is not None:
display.warning('_execute_remote_stat no longer honors the tmp parameter. Action'
' plugins should set self._connection._shell.tempdir to share'
' the tempdir')
del tmp # No longer used
module_args = dict( module_args = dict(
path=path, path=path,
follow=follow, follow=follow,
get_checksum=checksum, get_checksum=checksum,
checksum_algo='sha1', checksum_algo='sha1',
) )
mystat = self._execute_module(module_name='stat', module_args=module_args, task_vars=all_vars, tmp=tmp, delete_remote_tmp=(tmp is None), mystat = self._execute_module(module_name='stat', module_args=module_args, task_vars=all_vars,
wrap_async=False) wrap_async=False)
if mystat.get('failed'): if mystat.get('failed'):
@ -652,17 +664,24 @@ class ActionBase(with_metaclass(ABCMeta, object)):
update.update(options) update.update(options)
self.connection.set_options(update) self.connection.set_options(update)
def _execute_module(self, module_name=None, module_args=None, tmp=None, task_vars=None, persist_files=False, delete_remote_tmp=True, wrap_async=False): def _execute_module(self, module_name=None, module_args=None, tmp=None, task_vars=None, persist_files=False, delete_remote_tmp=None, wrap_async=False):
''' '''
Transfer and run a module along with its arguments. Transfer and run a module along with its arguments.
''' '''
if tmp is not None:
display.warning('_execute_module no longer honors the tmp parameter. Action plugins'
' should set self._connection._shell.tempdir to share the tempdir')
del tmp # No longer used
if delete_remote_tmp is not None:
display.warning('_execute_module no longer honors the delete_remote_tmp parameter.'
' Action plugins should check self._connection._shell.tempdir to'
' see if a tempdir existed before they were called to determine'
' if they are responsible for removing it.')
del delete_remote_tmp # No longer used
if task_vars is None: if task_vars is None:
task_vars = dict() task_vars = dict()
remote_module_path = None
args_file_path = None
remote_files = []
# if a module name was not specified for this execution, use the action from the task # if a module name was not specified for this execution, use the action from the task
if module_name is None: if module_name is None:
module_name = self._task.action module_name = self._task.action
@ -677,21 +696,22 @@ class ActionBase(with_metaclass(ABCMeta, object)):
if not shebang and module_style != 'binary': if not shebang and module_style != 'binary':
raise AnsibleError("module (%s) is missing interpreter line" % module_name) raise AnsibleError("module (%s) is missing interpreter line" % module_name)
if not self._is_pipelining_enabled(module_style, wrap_async): tempdir = self._connection._shell.tempdir
remote_module_path = None
# we might need remote tmp dir if not self._is_pipelining_enabled(module_style, wrap_async):
if not tmp: # we might need remote temp dir
if not self._connection._shell.tempdir or tmp is None or 'tmp' not in tmp: if tempdir is None:
tmp = self._make_tmp_path() self._make_tmp_path()
else: tempdir = self._connection._shell.tempdir
tmp = self._connection._shell.tempdir
remote_module_filename = self._connection._shell.get_remote_filename(module_path) remote_module_filename = self._connection._shell.get_remote_filename(module_path)
remote_module_path = self._connection._shell.join_path(tmp, remote_module_filename) remote_module_path = self._connection._shell.join_path(tempdir, remote_module_filename)
args_file_path = None
if module_style in ('old', 'non_native_want_json', 'binary'): if module_style in ('old', 'non_native_want_json', 'binary'):
# we'll also need a temp file to hold our module arguments # we'll also need a temp file to hold our module arguments
args_file_path = self._connection._shell.join_path(tmp, 'args') args_file_path = self._connection._shell.join_path(tempdir, 'args')
if remote_module_path or module_style != 'new': if remote_module_path or module_style != 'new':
display.debug("transferring module to remote %s" % remote_module_path) display.debug("transferring module to remote %s" % remote_module_path)
@ -712,8 +732,9 @@ class ActionBase(with_metaclass(ABCMeta, object)):
environment_string = self._compute_environment_string() environment_string = self._compute_environment_string()
if tmp and remote_module_path: remote_files = []
remote_files = [tmp, remote_module_path] if tempdir and remote_module_path:
remote_files = [tempdir, remote_module_path]
if args_file_path: if args_file_path:
remote_files.append(args_file_path) remote_files.append(args_file_path)
@ -727,7 +748,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
(async_module_style, shebang, async_module_data, async_module_path) = self._configure_module(module_name='async_wrapper', module_args=dict(), (async_module_style, shebang, async_module_data, async_module_path) = self._configure_module(module_name='async_wrapper', module_args=dict(),
task_vars=task_vars) task_vars=task_vars)
async_module_remote_filename = self._connection._shell.get_remote_filename(async_module_path) async_module_remote_filename = self._connection._shell.get_remote_filename(async_module_path)
remote_async_module_path = self._connection._shell.join_path(tmp, async_module_remote_filename) remote_async_module_path = self._connection._shell.join_path(tempdir, async_module_remote_filename)
self._transfer_data(remote_async_module_path, async_module_data) self._transfer_data(remote_async_module_path, async_module_data)
remote_files.append(remote_async_module_path) remote_files.append(remote_async_module_path)
@ -749,7 +770,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# maintain a fixed number of positional parameters for async_wrapper # maintain a fixed number of positional parameters for async_wrapper
async_cmd.append('_') async_cmd.append('_')
if not self._should_remove_tmp_path(tmp): if not self._should_remove_tmp_path(tempdir):
async_cmd.append("-preserve_tmp") async_cmd.append("-preserve_tmp")
cmd = " ".join(to_text(x) for x in async_cmd) cmd = " ".join(to_text(x) for x in async_cmd)
@ -763,7 +784,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
cmd = self._connection._shell.build_module_command(environment_string, shebang, cmd, arg_path=args_file_path).strip() cmd = self._connection._shell.build_module_command(environment_string, shebang, cmd, arg_path=args_file_path).strip()
# Fix permissions of the tmp path and tmp files. This should be called after all files have been transferred. # Fix permissions of the tempdir path and tempdir files. This should be called after all
# files have been transferred.
if remote_files: if remote_files:
# remove none/empty # remove none/empty
remote_files = [x for x in remote_files if x] remote_files = [x for x in remote_files if x]

View file

@ -44,6 +44,7 @@ class ActionModule(ActionBase):
self._supports_check_mode = True self._supports_check_mode = True
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
# Parse out any hostname:port patterns # Parse out any hostname:port patterns
new_name = self._task.args.get('name', self._task.args.get('hostname', self._task.args.get('host', None))) new_name = self._task.args.get('name', self._task.args.get('hostname', self._task.args.get('host', None)))

View file

@ -40,6 +40,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection != 'local': if self._play_context.connection != 'local':
return dict( return dict(
@ -83,5 +84,6 @@ class ActionModule(_ActionModule):
self._play_context.become = False self._play_context.become = False
self._play_context.become_method = None self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -39,6 +39,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection != 'local': if self._play_context.connection != 'local':
return dict( return dict(
@ -83,5 +84,5 @@ class ActionModule(_ActionModule):
self._play_context.become = False self._play_context.become = False
self._play_context.become_method = None self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -40,6 +40,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection == 'local': if self._play_context.connection == 'local':
provider = load_provider(asa_provider_spec, self._task.args) provider = load_provider(asa_provider_spec, self._task.args)
@ -69,6 +70,6 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path task_vars['ansible_socket'] = socket_path
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -84,8 +84,7 @@ class ActionModule(ActionBase):
self._supports_check_mode = False self._supports_check_mode = False
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
if task_vars is None: if task_vars is None:
task_vars = dict() task_vars = dict()
@ -104,7 +103,7 @@ class ActionModule(ActionBase):
raise AnsibleActionFail("src and dest are required") raise AnsibleActionFail("src and dest are required")
if boolean(remote_src, strict=False): if boolean(remote_src, strict=False):
result.update(self._execute_module(tmp=tmp, task_vars=task_vars)) result.update(self._execute_module(task_vars=task_vars))
raise _AnsibleActionDone() raise _AnsibleActionDone()
else: else:
try: try:
@ -124,7 +123,7 @@ class ActionModule(ActionBase):
path_checksum = checksum_s(path) path_checksum = checksum_s(path)
dest = self._remote_expand_user(dest) dest = self._remote_expand_user(dest)
dest_stat = self._execute_remote_stat(dest, all_vars=task_vars, follow=follow, tmp=tmp) dest_stat = self._execute_remote_stat(dest, all_vars=task_vars, follow=follow)
diff = {} diff = {}
@ -148,24 +147,24 @@ class ActionModule(ActionBase):
if self._play_context.diff: if self._play_context.diff:
diff = self._get_diff_data(dest, path, task_vars) diff = self._get_diff_data(dest, path, task_vars)
remote_path = self._connection._shell.join_path(tmp, 'src') remote_path = self._connection._shell.join_path(self._connection._shell.tempdir, 'src')
xfered = self._transfer_file(path, remote_path) xfered = self._transfer_file(path, remote_path)
# fix file permissions when the copy is done as a different user # fix file permissions when the copy is done as a different user
self._fixup_perms2((tmp, remote_path)) self._fixup_perms2((self._connection._shell.tempdir, remote_path))
new_module_args.update(dict(src=xfered,)) new_module_args.update(dict(src=xfered,))
res = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars, tmp=tmp) res = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars)
if diff: if diff:
res['diff'] = diff res['diff'] = diff
result.update(res) result.update(res)
else: else:
result.update(self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp)) result.update(self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars))
except AnsibleAction as e: except AnsibleAction as e:
result.update(e.result) result.update(e.result)
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -32,6 +32,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if 'that' not in self._task.args: if 'that' not in self._task.args:
raise AnsibleError('conditional required in "that" string') raise AnsibleError('conditional required in "that" string')

View file

@ -35,6 +35,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
source = self._task.args.get('src', None) source = self._task.args.get('src', None)

View file

@ -43,6 +43,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
provider = self._task.args.get('provider', {}) provider = self._task.args.get('provider', {})
if any(provider.values()): if any(provider.values()):
@ -93,7 +95,7 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result
@staticmethod @staticmethod

View file

@ -40,6 +40,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection != 'local': if self._play_context.connection != 'local':
return dict( return dict(
failed=True, failed=True,
@ -92,5 +94,5 @@ class ActionModule(_ActionModule):
self._task.args['transport'] = transport self._task.args['transport'] = transport
self._task.args['provider'] = provider self._task.args['provider'] = provider
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -38,6 +38,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -14,18 +14,17 @@ class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
self._supports_async = True self._supports_async = True
results = super(ActionModule, self).run(tmp, task_vars) results = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
# Command module has a special config option to turn off the command nanny warnings # Command module has a special config option to turn off the command nanny warnings
if 'warn' not in self._task.args: if 'warn' not in self._task.args:
self._task.args['warn'] = C.COMMAND_WARNINGS self._task.args['warn'] = C.COMMAND_WARNINGS
wrap_async = self._task.async_val and not self._connection.has_native_async wrap_async = self._task.async_val and not self._connection.has_native_async
results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars, wrap_async=wrap_async)) results = merge_hash(results, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
if not wrap_async: if not wrap_async:
# remove a temporary path we created # remove a temporary path we created
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return results return results

View file

@ -192,7 +192,7 @@ class ActionModule(ActionBase):
# remove action plugin only keys # remove action plugin only keys
return dict((k, v) for k, v in module_args.items() if k not in ('content', 'decrypt')) return dict((k, v) for k, v in module_args.items() if k not in ('content', 'decrypt'))
def _copy_file(self, source_full, source_rel, content, content_tempfile, dest, task_vars, tmp): def _copy_file(self, source_full, source_rel, content, content_tempfile, dest, task_vars):
decrypt = boolean(self._task.args.get('decrypt', True), strict=False) decrypt = boolean(self._task.args.get('decrypt', True), strict=False)
follow = boolean(self._task.args.get('follow', False), strict=False) follow = boolean(self._task.args.get('follow', False), strict=False)
force = boolean(self._task.args.get('force', 'yes'), strict=False) force = boolean(self._task.args.get('force', 'yes'), strict=False)
@ -224,7 +224,7 @@ class ActionModule(ActionBase):
dest_file = dest dest_file = dest
# Attempt to get remote file info # Attempt to get remote file info
dest_status = self._execute_remote_stat(dest_file, all_vars=task_vars, follow=follow, tmp=tmp, checksum=force) dest_status = self._execute_remote_stat(dest_file, all_vars=task_vars, follow=follow, checksum=force)
if dest_status['exists'] and dest_status['isdir']: if dest_status['exists'] and dest_status['isdir']:
# The dest is a directory. # The dest is a directory.
@ -237,7 +237,7 @@ class ActionModule(ActionBase):
else: else:
# Append the relative source location to the destination and get remote stats again # Append the relative source location to the destination and get remote stats again
dest_file = self._connection._shell.join_path(dest, source_rel) dest_file = self._connection._shell.join_path(dest, source_rel)
dest_status = self._execute_remote_stat(dest_file, all_vars=task_vars, follow=follow, tmp=tmp, checksum=force) dest_status = self._execute_remote_stat(dest_file, all_vars=task_vars, follow=follow, checksum=force)
if dest_status['exists'] and not force: if dest_status['exists'] and not force:
# remote_file exists so continue to next iteration. # remote_file exists so continue to next iteration.
@ -258,7 +258,7 @@ class ActionModule(ActionBase):
return result return result
# Define a remote directory that we will copy the file to. # Define a remote directory that we will copy the file to.
tmp_src = self._connection._shell.join_path(tmp, 'source') tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, 'source')
remote_path = None remote_path = None
@ -273,7 +273,7 @@ class ActionModule(ActionBase):
# fix file permissions when the copy is done as a different user # fix file permissions when the copy is done as a different user
if remote_path: if remote_path:
self._fixup_perms2((tmp, remote_path)) self._fixup_perms2((self._connection._shell.tempdir, remote_path))
if raw: if raw:
# Continue to next iteration if raw is defined. # Continue to next iteration if raw is defined.
@ -297,7 +297,7 @@ class ActionModule(ActionBase):
if lmode: if lmode:
new_module_args['mode'] = lmode new_module_args['mode'] = lmode
module_return = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars, tmp=tmp) module_return = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars)
else: else:
# no need to transfer the file, already correct hash, but still need to call # no need to transfer the file, already correct hash, but still need to call
@ -312,7 +312,7 @@ class ActionModule(ActionBase):
# If checksums match, and follow = True, find out if 'dest' is a link. If so, # If checksums match, and follow = True, find out if 'dest' is a link. If so,
# change it to point to the source of the link. # change it to point to the source of the link.
if follow: if follow:
dest_status_nofollow = self._execute_remote_stat(dest_file, all_vars=task_vars, tmp=tmp, follow=False) dest_status_nofollow = self._execute_remote_stat(dest_file, all_vars=task_vars, follow=False)
if dest_status_nofollow['islnk'] and 'lnk_source' in dest_status_nofollow.keys(): if dest_status_nofollow['islnk'] and 'lnk_source' in dest_status_nofollow.keys():
dest = dest_status_nofollow['lnk_source'] dest = dest_status_nofollow['lnk_source']
@ -331,7 +331,7 @@ class ActionModule(ActionBase):
new_module_args['mode'] = lmode new_module_args['mode'] = lmode
# Execute the file module. # Execute the file module.
module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp) module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars)
if not module_return.get('checksum'): if not module_return.get('checksum'):
module_return['checksum'] = local_checksum module_return['checksum'] = local_checksum
@ -391,8 +391,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
source = self._task.args.get('src', None) source = self._task.args.get('src', None)
content = self._task.args.get('content', None) content = self._task.args.get('content', None)
@ -492,7 +491,7 @@ class ActionModule(ActionBase):
for source_full, source_rel in source_files['files']: for source_full, source_rel in source_files['files']:
# copy files over. This happens first as directories that have # copy files over. This happens first as directories that have
# a file do not need to be created later # a file do not need to be created later
module_return = self._copy_file(source_full, source_rel, content, content_tempfile, dest, task_vars, tmp) module_return = self._copy_file(source_full, source_rel, content, content_tempfile, dest, task_vars)
if module_return is None: if module_return is None:
continue continue
@ -518,7 +517,7 @@ class ActionModule(ActionBase):
new_module_args['state'] = 'directory' new_module_args['state'] = 'directory'
new_module_args['mode'] = self._task.args.get('directory_mode', None) new_module_args['mode'] = self._task.args.get('directory_mode', None)
module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp) module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars)
module_executed = True module_executed = True
changed = changed or module_return.get('changed', False) changed = changed or module_return.get('changed', False)
@ -530,7 +529,7 @@ class ActionModule(ActionBase):
new_module_args['state'] = 'link' new_module_args['state'] = 'link'
new_module_args['force'] = True new_module_args['force'] = True
module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp) module_return = self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars)
module_executed = True module_executed = True
if module_return.get('failed'): if module_return.get('failed'):
@ -550,6 +549,6 @@ class ActionModule(ActionBase):
result.update(dict(dest=dest, src=source, changed=changed)) result.update(dict(dest=dest, src=source, changed=changed))
# Delete tmp path # Delete tmp path
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -42,6 +42,7 @@ class ActionModule(ActionBase):
return {"failed": True, "msg": "'msg' and 'var' are incompatible options"} return {"failed": True, "msg": "'msg' and 'var' are incompatible options"}
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
# get task verbosity # get task verbosity
verbosity = int(self._task.args.get('verbosity', 0)) verbosity = int(self._task.args.get('verbosity', 0))

View file

@ -41,6 +41,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -87,5 +89,5 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -45,6 +45,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -41,6 +41,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -87,5 +89,5 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -42,6 +42,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -41,6 +41,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -87,5 +89,5 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -45,6 +45,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -44,6 +44,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'local': if self._play_context.connection == 'local':
@ -85,5 +86,5 @@ class ActionModule(_ActionModule):
else: else:
conn.send_command('enable') conn.send_command('enable')
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -47,6 +47,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=to_text(exc)) return dict(failed=True, msg=to_text(exc))
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -39,6 +39,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -96,7 +98,7 @@ class ActionModule(_ActionModule):
conn.send_command('abort') conn.send_command('abort')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result
@staticmethod @staticmethod

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=to_text(exc)) return dict(failed=True, msg=to_text(exc))
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -31,6 +31,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
msg = 'Failed as requested from task' msg = 'Failed as requested from task'
if self._task.args and 'msg' in self._task.args: if self._task.args and 'msg' in self._task.args:

View file

@ -43,8 +43,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
try: try:
if self._play_context.check_mode: if self._play_context.check_mode:
@ -93,7 +92,7 @@ class ActionModule(ActionBase):
# use slurp if permissions are lacking or privilege escalation is needed # use slurp if permissions are lacking or privilege escalation is needed
remote_data = None remote_data = None
if remote_checksum in ('1', '2', None): if remote_checksum in ('1', '2', None):
slurpres = self._execute_module(module_name='slurp', module_args=dict(src=source), task_vars=task_vars, tmp=tmp) slurpres = self._execute_module(module_name='slurp', module_args=dict(src=source), task_vars=task_vars)
if slurpres.get('failed'): if slurpres.get('failed'):
if not fail_on_missing and (slurpres.get('msg').startswith('file not found') or remote_checksum == '1'): if not fail_on_missing and (slurpres.get('msg').startswith('file not found') or remote_checksum == '1'):
result['msg'] = "the remote file does not exist, not transferring, ignored" result['msg'] = "the remote file does not exist, not transferring, ignored"
@ -214,6 +213,6 @@ class ActionModule(ActionBase):
result.update(dict(changed=False, md5sum=local_md5, file=source, dest=dest, checksum=local_checksum)) result.update(dict(changed=False, md5sum=local_md5, file=source, dest=dest, checksum=local_checksum))
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -32,6 +32,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if 'key' not in self._task.args: if 'key' not in self._task.args:
result['failed'] = True result['failed'] = True

View file

@ -80,6 +80,8 @@ class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
""" Load yml files recursively from a directory. """ Load yml files recursively from a directory.
""" """
del tmp # tmp no longer has any effect
if task_vars is None: if task_vars is None:
task_vars = dict() task_vars = dict()
@ -139,7 +141,7 @@ class ActionModule(ActionBase):
scope[self.return_results_as_name] = results scope[self.return_results_as_name] = results
results = scope results = scope
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
if failed: if failed:
result['failed'] = failed result['failed'] = failed

View file

@ -39,6 +39,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -87,5 +89,5 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=to_text(exc)) return dict(failed=True, msg=to_text(exc))
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -39,6 +39,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'local': if self._play_context.connection == 'local':
@ -92,5 +94,5 @@ class ActionModule(_ActionModule):
conn.send_command('abort') conn.send_command('abort')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=to_text(exc)) return dict(failed=True, msg=to_text(exc))
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -40,6 +40,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection != 'local': if self._play_context.connection != 'local':
return dict( return dict(
@ -89,6 +90,6 @@ class ActionModule(_ActionModule):
self._play_context.become = False self._play_context.become = False
self._play_context.become_method = None self._play_context.become_method = None
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -41,9 +41,11 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
module = module_loader._load_module_source(self._task.action, module_loader.find_plugin(self._task.action)) module = module_loader._load_module_source(self._task.action, module_loader.find_plugin(self._task.action))
if not getattr(module, 'USE_PERSISTENT_CONNECTION', False): if not getattr(module, 'USE_PERSISTENT_CONNECTION', False):
return super(ActionModule, self).run(tmp, task_vars) return super(ActionModule, self).run(task_vars=task_vars)
socket_path = None socket_path = None
@ -95,5 +97,5 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(None, task_vars)
return result return result

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -44,6 +44,8 @@ _NETCONF_SUPPORTED_PLATFORMS = frozenset(['junos', 'iosxr'])
class ActionModule(ActionBase): class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
play_context = copy.deepcopy(self._play_context) play_context = copy.deepcopy(self._play_context)
play_context.network_os = self._get_network_os(task_vars) play_context.network_os = self._get_network_os(task_vars)
@ -110,7 +112,7 @@ class ActionModule(ActionBase):
if 'fail_on_missing_module' not in self._task.args: if 'fail_on_missing_module' not in self._task.args:
self._task.args['fail_on_missing_module'] = False self._task.args['fail_on_missing_module'] = False
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
module = self._get_implementation_module(play_context.network_os, self._task.action) module = self._get_implementation_module(play_context.network_os, self._task.action)

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -12,4 +12,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
return result return result

View file

@ -30,8 +30,7 @@ class ActionModule(ActionBase):
self._supports_async = True self._supports_async = True
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
if not result.get('skipped'): if not result.get('skipped'):
@ -44,7 +43,7 @@ class ActionModule(ActionBase):
wrap_async = self._task.async_val and not self._connection.has_native_async wrap_async = self._task.async_val and not self._connection.has_native_async
# do work! # do work!
result = merge_hash(result, self._execute_module(tmp=tmp, task_vars=task_vars, wrap_async=wrap_async)) result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
# hack to keep --verbose from showing all the setup module result # hack to keep --verbose from showing all the setup module result
# moved from setup module as now we filter out all _ansible_ from result # moved from setup module as now we filter out all _ansible_ from result
@ -53,6 +52,6 @@ class ActionModule(ActionBase):
if not wrap_async: if not wrap_async:
# remove a temporary path we created # remove a temporary path we created
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -39,6 +39,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -92,7 +94,7 @@ class ActionModule(_ActionModule):
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result
@staticmethod @staticmethod

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=str(exc)) return dict(failed=True, msg=str(exc))
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -42,6 +42,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -38,8 +38,7 @@ class ActionModule(ActionBase):
self._supports_async = True self._supports_async = True
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
module = self._task.args.get('use', 'auto') module = self._task.args.get('use', 'auto')
@ -78,6 +77,6 @@ class ActionModule(ActionBase):
finally: finally:
if not self._task.async_val: if not self._task.async_val:
# remove a temporary path we created # remove a temporary path we created
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -35,8 +35,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
src = self._task.args.get('src', None) src = self._task.args.get('src', None)
remote_src = boolean(self._task.args.get('remote_src', 'no'), strict=False) remote_src = boolean(self._task.args.get('remote_src', 'no'), strict=False)
@ -54,7 +53,7 @@ class ActionModule(ActionBase):
except AnsibleError as e: except AnsibleError as e:
raise AnsibleActionFail(to_native(e)) raise AnsibleActionFail(to_native(e))
tmp_src = self._connection._shell.join_path(tmp, os.path.basename(src)) tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, os.path.basename(src))
self._transfer_file(src, tmp_src) self._transfer_file(src, tmp_src)
self._fixup_perms2((tmp_src,)) self._fixup_perms2((tmp_src,))
@ -69,5 +68,5 @@ class ActionModule(ActionBase):
except AnsibleAction as e: except AnsibleAction as e:
result.update(e.result) result.update(e.result)
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -56,6 +56,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
duration_unit = 'minutes' duration_unit = 'minutes'
prompt = None prompt = None

View file

@ -31,6 +31,7 @@ class ActionModule(ActionBase):
self._display.warning('raw module does not support the environment keyword') self._display.warning('raw module does not support the environment keyword')
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._play_context.check_mode: if self._play_context.check_mode:
# in --check mode, always skip this module execution # in --check mode, always skip this module execution

View file

@ -41,8 +41,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
try: try:
creates = self._task.args.get('creates') creates = self._task.args.get('creates')
@ -90,7 +89,7 @@ class ActionModule(ActionBase):
if not self._play_context.check_mode: if not self._play_context.check_mode:
# transfer the file to a remote tmp location # transfer the file to a remote tmp location
tmp_src = self._connection._shell.join_path(tmp, os.path.basename(source)) tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, os.path.basename(source))
# Convert raw_params to text for the purpose of replacing the script since # Convert raw_params to text for the purpose of replacing the script since
# parts and tmp_src are both unicode strings and raw_params will be different # parts and tmp_src are both unicode strings and raw_params will be different
@ -134,6 +133,6 @@ class ActionModule(ActionBase):
except AnsibleAction as e: except AnsibleAction as e:
result.update(e.result) result.update(e.result)
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -37,8 +37,7 @@ class ActionModule(ActionBase):
self._supports_async = True self._supports_async = True
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
module = self._task.args.get('use', 'auto').lower() module = self._task.args.get('use', 'auto').lower()
@ -86,6 +85,6 @@ class ActionModule(ActionBase):
result.update(e.result) result.update(e.result)
finally: finally:
if not self._task.async_val: if not self._task.async_val:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -33,6 +33,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
facts = dict() facts = dict()

View file

@ -34,6 +34,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
stats = {'data': {}, 'per_host': False, 'aggregate': True} stats = {'data': {}, 'per_host': False, 'aggregate': True}

View file

@ -11,6 +11,8 @@ from ansible.utils.vars import merge_hash
class ActionModule(ActionBase): class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
# Shell module is implemented via command # Shell module is implemented via command
self._task.action = 'command' self._task.action = 'command'
self._task.args['_uses_shell'] = True self._task.args['_uses_shell'] = True

View file

@ -37,6 +37,7 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
provider = self._task.args.get('provider', {}) provider = self._task.args.get('provider', {})
@ -69,5 +70,5 @@ class ActionModule(_ActionModule):
else: else:
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection} return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -164,6 +164,7 @@ class ActionModule(ActionBase):
_tmp_args = self._task.args.copy() _tmp_args = self._task.args.copy()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
# Store remote connection type # Store remote connection type
self._remote_transport = self._connection.transport self._remote_transport = self._connection.transport

View file

@ -22,6 +22,7 @@ class ActionModule(ActionBase):
self._display.warning('The telnet task does not support the environment keyword') self._display.warning('The telnet task does not support the environment keyword')
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._play_context.check_mode: if self._play_context.check_mode:
# in --check mode, always skip this module execution # in --check mode, always skip this module execution

View file

@ -41,8 +41,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
source = self._task.args.get('src', None) source = self._task.args.get('src', None)
dest = self._task.args.get('dest', None) dest = self._task.args.get('dest', None)
@ -156,13 +155,13 @@ class ActionModule(ActionBase):
loader=self._loader, loader=self._loader,
templar=self._templar, templar=self._templar,
shared_loader_obj=self._shared_loader_obj) shared_loader_obj=self._shared_loader_obj)
result.update(copy_action.run(task_vars=task_vars, tmp=tmp)) result.update(copy_action.run(task_vars=task_vars))
finally: finally:
shutil.rmtree(local_tempdir) shutil.rmtree(local_tempdir)
except AnsibleAction as e: except AnsibleAction as e:
result.update(e.result) result.update(e.result)
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -36,8 +36,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
tmp = self._connection._shell.tempdir
source = self._task.args.get('src', None) source = self._task.args.get('src', None)
dest = self._task.args.get('dest', None) dest = self._task.args.get('dest', None)
@ -85,7 +84,7 @@ class ActionModule(ActionBase):
if not remote_src: if not remote_src:
# transfer the file to a remote tmp location # transfer the file to a remote tmp location
tmp_src = self._connection._shell.join_path(tmp, 'source') tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, 'source')
self._transfer_file(source, tmp_src) self._transfer_file(source, tmp_src)
# handle diff mode client side # handle diff mode client side
@ -93,7 +92,7 @@ class ActionModule(ActionBase):
if not remote_src: if not remote_src:
# fix file permissions when the copy is done as a different user # fix file permissions when the copy is done as a different user
self._fixup_perms2((tmp, tmp_src)) self._fixup_perms2((self._connection._shell.tempdir, tmp_src))
# Build temporary module_args. # Build temporary module_args.
new_module_args = self._task.args.copy() new_module_args = self._task.args.copy()
new_module_args.update( new_module_args.update(
@ -121,5 +120,5 @@ class ActionModule(ActionBase):
except AnsibleAction as e: except AnsibleAction as e:
result.update(e.result) result.update(e.result)
finally: finally:
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -39,6 +39,8 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
del tmp # tmp no longer has any effect
socket_path = None socket_path = None
if self._play_context.connection == 'network_cli': if self._play_context.connection == 'network_cli':
@ -83,5 +85,5 @@ class ActionModule(_ActionModule):
conn.send_command('abort') conn.send_command('abort')
out = conn.get_prompt() out = conn.get_prompt()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

@ -44,6 +44,7 @@ class ActionModule(_ActionModule):
return dict(failed=True, msg=exc.message) return dict(failed=True, msg=exc.message)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if self._task.args.get('backup') and result.get('__backup__'): if self._task.args.get('backup') and result.get('__backup__'):
# User requested backup and no error occurred in module. # User requested backup and no error occurred in module.

View file

@ -74,6 +74,7 @@ class ActionModule(ActionBase):
return dict(skipped=True) return dict(skipped=True)
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
def ping_module_test(connect_timeout): def ping_module_test(connect_timeout):
''' Test ping module, if available ''' ''' Test ping module, if available '''
@ -86,9 +87,9 @@ class ActionModule(ActionBase):
# Use win_ping on winrm/powershell, else use ping # Use win_ping on winrm/powershell, else use ping
if hasattr(self._connection, '_shell_type') and self._connection._shell_type == 'powershell': if hasattr(self._connection, '_shell_type') and self._connection._shell_type == 'powershell':
ping_result = self._execute_module(module_name='win_ping', module_args=dict(), tmp=tmp, task_vars=task_vars) ping_result = self._execute_module(module_name='win_ping', module_args=dict(), task_vars=task_vars)
else: else:
ping_result = self._execute_module(module_name='ping', module_args=dict(), tmp=tmp, task_vars=task_vars) ping_result = self._execute_module(module_name='ping', module_args=dict(), task_vars=task_vars)
# Test module output # Test module output
if ping_result['ping'] != 'pong': if ping_result['ping'] != 'pong':

View file

@ -281,8 +281,7 @@ class ActionModule(ActionBase):
copy_result = self._execute_module(module_name="copy", copy_result = self._execute_module(module_name="copy",
module_args=copy_args, module_args=copy_args,
task_vars=task_vars, task_vars=task_vars)
tmp=tmp)
return copy_result return copy_result
@ -325,8 +324,7 @@ class ActionModule(ActionBase):
module_return = self._execute_module(module_name='copy', module_return = self._execute_module(module_name='copy',
module_args=copy_args, module_args=copy_args,
task_vars=task_vars, task_vars=task_vars)
tmp=tmp)
os.removedirs(os.path.dirname(zip_path)) os.removedirs(os.path.dirname(zip_path))
return module_return return module_return
@ -336,6 +334,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
source = self._task.args.get('src', None) source = self._task.args.get('src', None)
content = self._task.args.get('content', None) content = self._task.args.get('content', None)
@ -482,22 +481,21 @@ class ActionModule(ActionBase):
query_args.pop('content', None) query_args.pop('content', None)
query_return = self._execute_module(module_args=query_args, query_return = self._execute_module(module_args=query_args,
task_vars=task_vars, task_vars=task_vars)
tmp=tmp)
if query_return.get('failed') is True: if query_return.get('failed') is True:
result.update(query_return) result.update(query_return)
return result return result
if len(query_return['files']) > 0 or len(query_return['directories']) > 0 and tmp is None: if len(query_return['files']) > 0 or len(query_return['directories']) > 0 and self._connection._shell.tempdir is None:
tmp = self._make_tmp_path() self._connection._shell.tempdir = self._make_tmp_path()
if len(query_return['files']) == 1 and len(query_return['directories']) == 0: if len(query_return['files']) == 1 and len(query_return['directories']) == 0:
# we only need to copy 1 file, don't mess around with zips # we only need to copy 1 file, don't mess around with zips
file_src = query_return['files'][0]['src'] file_src = query_return['files'][0]['src']
file_dest = query_return['files'][0]['dest'] file_dest = query_return['files'][0]['dest']
copy_result = self._copy_single_file(file_src, dest, file_dest, copy_result = self._copy_single_file(file_src, dest, file_dest,
task_vars, tmp) task_vars, self._connection._shell.tempdir)
result['changed'] = True result['changed'] = True
if copy_result.get('failed') is True: if copy_result.get('failed') is True:
@ -509,7 +507,7 @@ class ActionModule(ActionBase):
# TODO: handle symlinks # TODO: handle symlinks
result.update(self._copy_zip_file(dest, source_files['files'], result.update(self._copy_zip_file(dest, source_files['files'],
source_files['directories'], source_files['directories'],
task_vars, tmp)) task_vars, self._connection._shell.tempdir))
result['changed'] = True result['changed'] = True
else: else:
# no operations need to occur # no operations need to occur
@ -518,5 +516,5 @@ class ActionModule(ActionBase):
# remove the content temp file and remote tmp file if it was created # remove the content temp file and remote tmp file if it was created
self._remove_tempfile_if_content_defined(content, content_tempfile) self._remove_tempfile_if_content_defined(content, content_tempfile)
self._remove_tmp_path(tmp) self._remove_tmp_path(self._connection._shell.tempdir)
return result return result

View file

@ -73,6 +73,7 @@ class ActionModule(ActionBase):
task_vars = dict() task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if result.get('skipped', False) or result.get('failed', False): if result.get('skipped', False) or result.get('failed', False):
return result return result

View file

@ -133,6 +133,7 @@ class ActionModule(ActionBase):
self._supports_async = True self._supports_async = True
result = super(ActionModule, self).run(tmp, task_vars) result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
category_names = self._task.args.get('category_names', [ category_names = self._task.args.get('category_names', [
'CriticalUpdates', 'CriticalUpdates',