diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index e7860f46a0f..7a5f10cb357 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -66,9 +66,9 @@ class ActionBase(with_metaclass(ABCMeta, object)): tasks. Everything else in this base class is a helper method for the action plugin to do that. - :kwarg tmp: Temporary directory. Sometimes an action plugin sets up - a temporary directory and then calls another module. This parameter - allows us to reuse the same directory for both. + :kwarg tmp: Deprecated parameter. This is no longer used. An action plugin that calls + another one and wants to use the same remote tmp for both should set + self._connection._shell.tempdir rather than this parameter. :kwarg task_vars: The variables (host vars, group vars, config vars, etc) associated with this task. :returns: dictionary of results from the module @@ -80,6 +80,12 @@ class ActionBase(with_metaclass(ABCMeta, object)): 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: raise AnsibleActionFail('async is not supported for this task.') 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: 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() - else: - self._connection._shell.tempdir = tmp return result @@ -311,6 +315,8 @@ class ActionBase(with_metaclass(ABCMeta, object)): if tmp_rm_data.get('rc', 0) != 0: 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.'))) + else: + self._connection._shell.tempdir = None def _transfer_file(self, 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. ''' + 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( path=path, follow=follow, get_checksum=checksum, 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) if mystat.get('failed'): @@ -652,17 +664,24 @@ class ActionBase(with_metaclass(ABCMeta, object)): update.update(options) 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. ''' + 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: 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 module_name is None: module_name = self._task.action @@ -677,21 +696,22 @@ class ActionBase(with_metaclass(ABCMeta, object)): if not shebang and module_style != 'binary': 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 tmp: - if not self._connection._shell.tempdir or tmp is None or 'tmp' not in tmp: - tmp = self._make_tmp_path() - else: - tmp = self._connection._shell.tempdir + if not self._is_pipelining_enabled(module_style, wrap_async): + # we might need remote temp dir + if tempdir is None: + self._make_tmp_path() + tempdir = self._connection._shell.tempdir 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'): # 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': 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() - if tmp and remote_module_path: - remote_files = [tmp, remote_module_path] + remote_files = [] + if tempdir and remote_module_path: + remote_files = [tempdir, remote_module_path] if 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(), task_vars=task_vars) 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) 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 async_cmd.append('_') - if not self._should_remove_tmp_path(tmp): + if not self._should_remove_tmp_path(tempdir): async_cmd.append("-preserve_tmp") 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() - # 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: # remove none/empty remote_files = [x for x in remote_files if x] diff --git a/lib/ansible/plugins/action/add_host.py b/lib/ansible/plugins/action/add_host.py index cb4f2a03171..cd4bb40e78e 100644 --- a/lib/ansible/plugins/action/add_host.py +++ b/lib/ansible/plugins/action/add_host.py @@ -44,6 +44,7 @@ class ActionModule(ActionBase): self._supports_check_mode = True result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect # Parse out any hostname:port patterns new_name = self._task.args.get('name', self._task.args.get('hostname', self._task.args.get('host', None))) diff --git a/lib/ansible/plugins/action/aireos.py b/lib/ansible/plugins/action/aireos.py index 710eeb842a0..4714cadba5d 100644 --- a/lib/ansible/plugins/action/aireos.py +++ b/lib/ansible/plugins/action/aireos.py @@ -40,6 +40,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect if self._play_context.connection != 'local': return dict( @@ -83,5 +84,6 @@ class ActionModule(_ActionModule): self._play_context.become = False 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 diff --git a/lib/ansible/plugins/action/aireos_config.py b/lib/ansible/plugins/action/aireos_config.py index c92276846ee..99abd86bdf4 100644 --- a/lib/ansible/plugins/action/aireos_config.py +++ b/lib/ansible/plugins/action/aireos_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/aruba.py b/lib/ansible/plugins/action/aruba.py index ea3aabe76a1..2c2fcc00370 100644 --- a/lib/ansible/plugins/action/aruba.py +++ b/lib/ansible/plugins/action/aruba.py @@ -39,6 +39,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect if self._play_context.connection != 'local': return dict( @@ -83,5 +84,5 @@ class ActionModule(_ActionModule): self._play_context.become = False 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 diff --git a/lib/ansible/plugins/action/aruba_config.py b/lib/ansible/plugins/action/aruba_config.py index 509cd67c10a..bff406b150b 100644 --- a/lib/ansible/plugins/action/aruba_config.py +++ b/lib/ansible/plugins/action/aruba_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/asa.py b/lib/ansible/plugins/action/asa.py index 5424a32b7bf..40f775a970f 100644 --- a/lib/ansible/plugins/action/asa.py +++ b/lib/ansible/plugins/action/asa.py @@ -40,6 +40,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect if self._play_context.connection == 'local': provider = load_provider(asa_provider_spec, self._task.args) @@ -69,6 +70,6 @@ class ActionModule(_ActionModule): 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 diff --git a/lib/ansible/plugins/action/asa_config.py b/lib/ansible/plugins/action/asa_config.py index 98200856e48..bd8916b65a1 100644 --- a/lib/ansible/plugins/action/asa_config.py +++ b/lib/ansible/plugins/action/asa_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/assemble.py b/lib/ansible/plugins/action/assemble.py index d4589ee61ac..499943e0d99 100644 --- a/lib/ansible/plugins/action/assemble.py +++ b/lib/ansible/plugins/action/assemble.py @@ -84,8 +84,7 @@ class ActionModule(ActionBase): self._supports_check_mode = False result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect if task_vars is None: task_vars = dict() @@ -104,7 +103,7 @@ class ActionModule(ActionBase): raise AnsibleActionFail("src and dest are required") 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() else: try: @@ -124,7 +123,7 @@ class ActionModule(ActionBase): path_checksum = checksum_s(path) 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 = {} @@ -148,24 +147,24 @@ class ActionModule(ActionBase): if self._play_context.diff: 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) # 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,)) - 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: res['diff'] = diff result.update(res) 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: result.update(e.result) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/assert.py b/lib/ansible/plugins/action/assert.py index 808881b1ff5..bf9fc6bb967 100644 --- a/lib/ansible/plugins/action/assert.py +++ b/lib/ansible/plugins/action/assert.py @@ -32,6 +32,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect if 'that' not in self._task.args: raise AnsibleError('conditional required in "that" string') diff --git a/lib/ansible/plugins/action/aws_s3.py b/lib/ansible/plugins/action/aws_s3.py index 5e0085d0685..dfe7f2d428a 100644 --- a/lib/ansible/plugins/action/aws_s3.py +++ b/lib/ansible/plugins/action/aws_s3.py @@ -35,6 +35,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect source = self._task.args.get('src', None) diff --git a/lib/ansible/plugins/action/bigip.py b/lib/ansible/plugins/action/bigip.py index e11cff45d49..f4e399982f3 100644 --- a/lib/ansible/plugins/action/bigip.py +++ b/lib/ansible/plugins/action/bigip.py @@ -43,6 +43,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + if self._play_context.connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): @@ -93,7 +95,7 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result @staticmethod diff --git a/lib/ansible/plugins/action/ce.py b/lib/ansible/plugins/action/ce.py index 92c7affb720..f896af43692 100644 --- a/lib/ansible/plugins/action/ce.py +++ b/lib/ansible/plugins/action/ce.py @@ -40,6 +40,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + if self._play_context.connection != 'local': return dict( failed=True, @@ -92,5 +94,5 @@ class ActionModule(_ActionModule): self._task.args['transport'] = transport self._task.args['provider'] = provider - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/ce_config.py b/lib/ansible/plugins/action/ce_config.py index f97aad09fcc..a798d1f9c39 100644 --- a/lib/ansible/plugins/action/ce_config.py +++ b/lib/ansible/plugins/action/ce_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/ce_template.py b/lib/ansible/plugins/action/ce_template.py index 2c4e1f0ab50..8d62b25647d 100644 --- a/lib/ansible/plugins/action/ce_template.py +++ b/lib/ansible/plugins/action/ce_template.py @@ -38,6 +38,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/command.py b/lib/ansible/plugins/action/command.py index 63a52a0e2eb..7b263f6b28d 100644 --- a/lib/ansible/plugins/action/command.py +++ b/lib/ansible/plugins/action/command.py @@ -14,18 +14,17 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): self._supports_async = True results = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect # Command module has a special config option to turn off the command nanny warnings if 'warn' not in self._task.args: self._task.args['warn'] = C.COMMAND_WARNINGS 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: # remove a temporary path we created - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return results diff --git a/lib/ansible/plugins/action/copy.py b/lib/ansible/plugins/action/copy.py index a9901a4cd5b..a5cbecf35b8 100644 --- a/lib/ansible/plugins/action/copy.py +++ b/lib/ansible/plugins/action/copy.py @@ -192,7 +192,7 @@ class ActionModule(ActionBase): # remove action plugin only keys 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) follow = boolean(self._task.args.get('follow', False), strict=False) force = boolean(self._task.args.get('force', 'yes'), strict=False) @@ -224,7 +224,7 @@ class ActionModule(ActionBase): dest_file = dest # 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']: # The dest is a directory. @@ -237,7 +237,7 @@ class ActionModule(ActionBase): else: # Append the relative source location to the destination and get remote stats again 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: # remote_file exists so continue to next iteration. @@ -258,7 +258,7 @@ class ActionModule(ActionBase): return result # 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 @@ -273,7 +273,7 @@ class ActionModule(ActionBase): # fix file permissions when the copy is done as a different user if remote_path: - self._fixup_perms2((tmp, remote_path)) + self._fixup_perms2((self._connection._shell.tempdir, remote_path)) if raw: # Continue to next iteration if raw is defined. @@ -297,7 +297,7 @@ class ActionModule(ActionBase): if 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: # 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, # change it to point to the source of the link. 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(): dest = dest_status_nofollow['lnk_source'] @@ -331,7 +331,7 @@ class ActionModule(ActionBase): new_module_args['mode'] = lmode # 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'): module_return['checksum'] = local_checksum @@ -391,8 +391,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect source = self._task.args.get('src', None) content = self._task.args.get('content', None) @@ -492,7 +491,7 @@ class ActionModule(ActionBase): for source_full, source_rel in source_files['files']: # copy files over. This happens first as directories that have # 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: continue @@ -518,7 +517,7 @@ class ActionModule(ActionBase): new_module_args['state'] = 'directory' 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 changed = changed or module_return.get('changed', False) @@ -530,7 +529,7 @@ class ActionModule(ActionBase): new_module_args['state'] = 'link' 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 if module_return.get('failed'): @@ -550,6 +549,6 @@ class ActionModule(ActionBase): result.update(dict(dest=dest, src=source, changed=changed)) # Delete tmp path - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/debug.py b/lib/ansible/plugins/action/debug.py index 06337e564ca..b0473d9288e 100644 --- a/lib/ansible/plugins/action/debug.py +++ b/lib/ansible/plugins/action/debug.py @@ -42,6 +42,7 @@ class ActionModule(ActionBase): return {"failed": True, "msg": "'msg' and 'var' are incompatible options"} result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect # get task verbosity verbosity = int(self._task.args.get('verbosity', 0)) diff --git a/lib/ansible/plugins/action/dellos10.py b/lib/ansible/plugins/action/dellos10.py index 83fae9a55c1..4bc461f8dff 100644 --- a/lib/ansible/plugins/action/dellos10.py +++ b/lib/ansible/plugins/action/dellos10.py @@ -41,6 +41,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -87,5 +89,5 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/dellos10_config.py b/lib/ansible/plugins/action/dellos10_config.py index 77769b16c79..ab8b60cdbd4 100644 --- a/lib/ansible/plugins/action/dellos10_config.py +++ b/lib/ansible/plugins/action/dellos10_config.py @@ -45,6 +45,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/dellos6.py b/lib/ansible/plugins/action/dellos6.py index 387cdfa00d4..b469cefab4f 100644 --- a/lib/ansible/plugins/action/dellos6.py +++ b/lib/ansible/plugins/action/dellos6.py @@ -41,6 +41,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -87,5 +89,5 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/dellos6_config.py b/lib/ansible/plugins/action/dellos6_config.py index 22e2961d46d..b02ee7232d6 100644 --- a/lib/ansible/plugins/action/dellos6_config.py +++ b/lib/ansible/plugins/action/dellos6_config.py @@ -42,6 +42,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/dellos9.py b/lib/ansible/plugins/action/dellos9.py index 463a4c5a9e3..85b518f8f02 100644 --- a/lib/ansible/plugins/action/dellos9.py +++ b/lib/ansible/plugins/action/dellos9.py @@ -41,6 +41,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -87,5 +89,5 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/dellos9_config.py b/lib/ansible/plugins/action/dellos9_config.py index aded696987a..88d4dd42b46 100644 --- a/lib/ansible/plugins/action/dellos9_config.py +++ b/lib/ansible/plugins/action/dellos9_config.py @@ -45,6 +45,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/enos.py b/lib/ansible/plugins/action/enos.py index 75c70f0ade5..a5da914839c 100644 --- a/lib/ansible/plugins/action/enos.py +++ b/lib/ansible/plugins/action/enos.py @@ -44,6 +44,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect socket_path = None if self._play_context.connection == 'local': @@ -85,5 +86,5 @@ class ActionModule(_ActionModule): else: conn.send_command('enable') - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/enos_config.py b/lib/ansible/plugins/action/enos_config.py index 75bff2f4a17..b7080c6e60b 100644 --- a/lib/ansible/plugins/action/enos_config.py +++ b/lib/ansible/plugins/action/enos_config.py @@ -47,6 +47,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=to_text(exc)) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py index 4fd309c862f..3cb17667154 100644 --- a/lib/ansible/plugins/action/eos.py +++ b/lib/ansible/plugins/action/eos.py @@ -39,6 +39,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -96,7 +98,7 @@ class ActionModule(_ActionModule): conn.send_command('abort') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result @staticmethod diff --git a/lib/ansible/plugins/action/eos_config.py b/lib/ansible/plugins/action/eos_config.py index 276f7b0e3c2..7ddeed1bb12 100644 --- a/lib/ansible/plugins/action/eos_config.py +++ b/lib/ansible/plugins/action/eos_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=to_text(exc)) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/fail.py b/lib/ansible/plugins/action/fail.py index c78f1683a95..9a9da51d755 100644 --- a/lib/ansible/plugins/action/fail.py +++ b/lib/ansible/plugins/action/fail.py @@ -31,6 +31,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect msg = 'Failed as requested from task' if self._task.args and 'msg' in self._task.args: diff --git a/lib/ansible/plugins/action/fetch.py b/lib/ansible/plugins/action/fetch.py index f87c0b55359..64f81a1032b 100644 --- a/lib/ansible/plugins/action/fetch.py +++ b/lib/ansible/plugins/action/fetch.py @@ -43,8 +43,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect try: if self._play_context.check_mode: @@ -93,7 +92,7 @@ class ActionModule(ActionBase): # use slurp if permissions are lacking or privilege escalation is needed remote_data = 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 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" @@ -214,6 +213,6 @@ class ActionModule(ActionBase): result.update(dict(changed=False, md5sum=local_md5, file=source, dest=dest, checksum=local_checksum)) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/fortios_config.py b/lib/ansible/plugins/action/fortios_config.py index 6692569598f..9cac71c55b0 100644 --- a/lib/ansible/plugins/action/fortios_config.py +++ b/lib/ansible/plugins/action/fortios_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/group_by.py b/lib/ansible/plugins/action/group_by.py index 1266803a59d..58749d8470c 100644 --- a/lib/ansible/plugins/action/group_by.py +++ b/lib/ansible/plugins/action/group_by.py @@ -32,6 +32,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect if 'key' not in self._task.args: result['failed'] = True diff --git a/lib/ansible/plugins/action/include_vars.py b/lib/ansible/plugins/action/include_vars.py index 5f89b1e7035..7ef24e9b3a6 100644 --- a/lib/ansible/plugins/action/include_vars.py +++ b/lib/ansible/plugins/action/include_vars.py @@ -80,6 +80,8 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): """ Load yml files recursively from a directory. """ + del tmp # tmp no longer has any effect + if task_vars is None: task_vars = dict() @@ -139,7 +141,7 @@ class ActionModule(ActionBase): scope[self.return_results_as_name] = results results = scope - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) if failed: result['failed'] = failed diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 13dbb47ac50..2cfca1a374b 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -39,6 +39,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -87,5 +89,5 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/ios_config.py b/lib/ansible/plugins/action/ios_config.py index 5471bcb4559..bf47cef9bc0 100644 --- a/lib/ansible/plugins/action/ios_config.py +++ b/lib/ansible/plugins/action/ios_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=to_text(exc)) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/iosxr.py b/lib/ansible/plugins/action/iosxr.py index c9efaeae1f5..40a39b68df1 100644 --- a/lib/ansible/plugins/action/iosxr.py +++ b/lib/ansible/plugins/action/iosxr.py @@ -39,6 +39,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'local': @@ -92,5 +94,5 @@ class ActionModule(_ActionModule): conn.send_command('abort') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/iosxr_config.py b/lib/ansible/plugins/action/iosxr_config.py index 26a3893d35f..cdc2eccced4 100644 --- a/lib/ansible/plugins/action/iosxr_config.py +++ b/lib/ansible/plugins/action/iosxr_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=to_text(exc)) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/ironware.py b/lib/ansible/plugins/action/ironware.py index fa8da417bb8..5033af9436d 100644 --- a/lib/ansible/plugins/action/ironware.py +++ b/lib/ansible/plugins/action/ironware.py @@ -40,6 +40,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect if self._play_context.connection != 'local': return dict( @@ -89,6 +90,6 @@ class ActionModule(_ActionModule): self._play_context.become = False 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 diff --git a/lib/ansible/plugins/action/ironware_config.py b/lib/ansible/plugins/action/ironware_config.py index 6406d4c4655..06609f1b6a1 100644 --- a/lib/ansible/plugins/action/ironware_config.py +++ b/lib/ansible/plugins/action/ironware_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/junos.py b/lib/ansible/plugins/action/junos.py index 2fa40a5e67d..dcba154a750 100644 --- a/lib/ansible/plugins/action/junos.py +++ b/lib/ansible/plugins/action/junos.py @@ -41,9 +41,11 @@ except ImportError: class ActionModule(_ActionModule): 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)) 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 @@ -95,5 +97,5 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(None, task_vars) return result diff --git a/lib/ansible/plugins/action/junos_config.py b/lib/ansible/plugins/action/junos_config.py index 2b29171ded9..ea0687ec34e 100644 --- a/lib/ansible/plugins/action/junos_config.py +++ b/lib/ansible/plugins/action/junos_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/net_banner.py b/lib/ansible/plugins/action/net_banner.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_banner.py +++ b/lib/ansible/plugins/action/net_banner.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_base.py b/lib/ansible/plugins/action/net_base.py index 1aaa1024e57..dd0fcf6d3e1 100644 --- a/lib/ansible/plugins/action/net_base.py +++ b/lib/ansible/plugins/action/net_base.py @@ -44,6 +44,8 @@ _NETCONF_SUPPORTED_PLATFORMS = frozenset(['junos', 'iosxr']) class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None play_context = copy.deepcopy(self._play_context) 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: 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) diff --git a/lib/ansible/plugins/action/net_config.py b/lib/ansible/plugins/action/net_config.py index a6437286291..85214626079 100644 --- a/lib/ansible/plugins/action/net_config.py +++ b/lib/ansible/plugins/action/net_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/net_interface.py b/lib/ansible/plugins/action/net_interface.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_interface.py +++ b/lib/ansible/plugins/action/net_interface.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_l2_interface.py b/lib/ansible/plugins/action/net_l2_interface.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_l2_interface.py +++ b/lib/ansible/plugins/action/net_l2_interface.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_l3_interface.py b/lib/ansible/plugins/action/net_l3_interface.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_l3_interface.py +++ b/lib/ansible/plugins/action/net_l3_interface.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_linkagg.py b/lib/ansible/plugins/action/net_linkagg.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_linkagg.py +++ b/lib/ansible/plugins/action/net_linkagg.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_lldp.py b/lib/ansible/plugins/action/net_lldp.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_lldp.py +++ b/lib/ansible/plugins/action/net_lldp.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_lldp_interface.py b/lib/ansible/plugins/action/net_lldp_interface.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_lldp_interface.py +++ b/lib/ansible/plugins/action/net_lldp_interface.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_logging.py b/lib/ansible/plugins/action/net_logging.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_logging.py +++ b/lib/ansible/plugins/action/net_logging.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_ping.py b/lib/ansible/plugins/action/net_ping.py index 6cc78dd8825..afcf49dede0 100644 --- a/lib/ansible/plugins/action/net_ping.py +++ b/lib/ansible/plugins/action/net_ping.py @@ -12,4 +12,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_static_route.py b/lib/ansible/plugins/action/net_static_route.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_static_route.py +++ b/lib/ansible/plugins/action/net_static_route.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_system.py b/lib/ansible/plugins/action/net_system.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_system.py +++ b/lib/ansible/plugins/action/net_system.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_user.py b/lib/ansible/plugins/action/net_user.py index a4ee4db0b6e..81f46f197a0 100644 --- a/lib/ansible/plugins/action/net_user.py +++ b/lib/ansible/plugins/action/net_user.py @@ -23,4 +23,5 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_vlan.py b/lib/ansible/plugins/action/net_vlan.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_vlan.py +++ b/lib/ansible/plugins/action/net_vlan.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/net_vrf.py b/lib/ansible/plugins/action/net_vrf.py index cad73f8a26a..d8617842d81 100644 --- a/lib/ansible/plugins/action/net_vrf.py +++ b/lib/ansible/plugins/action/net_vrf.py @@ -23,5 +23,6 @@ from ansible.plugins.action.net_base import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect return result diff --git a/lib/ansible/plugins/action/normal.py b/lib/ansible/plugins/action/normal.py index ad2c04bd50e..3b73174a0cd 100644 --- a/lib/ansible/plugins/action/normal.py +++ b/lib/ansible/plugins/action/normal.py @@ -30,8 +30,7 @@ class ActionModule(ActionBase): self._supports_async = True result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect 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 # 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 # moved from setup module as now we filter out all _ansible_ from result @@ -53,6 +52,6 @@ class ActionModule(ActionBase): if not wrap_async: # remove a temporary path we created - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index 52ceab85fd2..00cadbfdc58 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -39,6 +39,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -92,7 +94,7 @@ class ActionModule(_ActionModule): conn.send_command('exit') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result @staticmethod diff --git a/lib/ansible/plugins/action/nxos_config.py b/lib/ansible/plugins/action/nxos_config.py index 125c7779842..2d61a224e6c 100644 --- a/lib/ansible/plugins/action/nxos_config.py +++ b/lib/ansible/plugins/action/nxos_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=str(exc)) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/onyx_config.py b/lib/ansible/plugins/action/onyx_config.py index b0cbc23ffa3..3b84e2adb54 100644 --- a/lib/ansible/plugins/action/onyx_config.py +++ b/lib/ansible/plugins/action/onyx_config.py @@ -42,6 +42,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/package.py b/lib/ansible/plugins/action/package.py index 54a9d9737c9..0e220318057 100644 --- a/lib/ansible/plugins/action/package.py +++ b/lib/ansible/plugins/action/package.py @@ -38,8 +38,7 @@ class ActionModule(ActionBase): self._supports_async = True result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect module = self._task.args.get('use', 'auto') @@ -78,6 +77,6 @@ class ActionModule(ActionBase): finally: if not self._task.async_val: # remove a temporary path we created - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/patch.py b/lib/ansible/plugins/action/patch.py index 12e64d31c63..d2d9dc10fd0 100644 --- a/lib/ansible/plugins/action/patch.py +++ b/lib/ansible/plugins/action/patch.py @@ -35,8 +35,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect src = self._task.args.get('src', None) remote_src = boolean(self._task.args.get('remote_src', 'no'), strict=False) @@ -54,7 +53,7 @@ class ActionModule(ActionBase): except AnsibleError as 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._fixup_perms2((tmp_src,)) @@ -69,5 +68,5 @@ class ActionModule(ActionBase): except AnsibleAction as e: result.update(e.result) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py index 212aaab5a71..0813aecad2e 100644 --- a/lib/ansible/plugins/action/pause.py +++ b/lib/ansible/plugins/action/pause.py @@ -56,6 +56,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect duration_unit = 'minutes' prompt = None diff --git a/lib/ansible/plugins/action/raw.py b/lib/ansible/plugins/action/raw.py index cf43ee69947..b82ed34037e 100644 --- a/lib/ansible/plugins/action/raw.py +++ b/lib/ansible/plugins/action/raw.py @@ -31,6 +31,7 @@ class ActionModule(ActionBase): self._display.warning('raw module does not support the environment keyword') result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect if self._play_context.check_mode: # in --check mode, always skip this module execution diff --git a/lib/ansible/plugins/action/script.py b/lib/ansible/plugins/action/script.py index efdb9888b71..83ab129cd0c 100644 --- a/lib/ansible/plugins/action/script.py +++ b/lib/ansible/plugins/action/script.py @@ -41,8 +41,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect try: creates = self._task.args.get('creates') @@ -90,7 +89,7 @@ class ActionModule(ActionBase): if not self._play_context.check_mode: # 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 # 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: result.update(e.result) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/service.py b/lib/ansible/plugins/action/service.py index bdf4d32dbc8..12893b2656e 100644 --- a/lib/ansible/plugins/action/service.py +++ b/lib/ansible/plugins/action/service.py @@ -37,8 +37,7 @@ class ActionModule(ActionBase): self._supports_async = True result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect module = self._task.args.get('use', 'auto').lower() @@ -86,6 +85,6 @@ class ActionModule(ActionBase): result.update(e.result) finally: if not self._task.async_val: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/set_fact.py b/lib/ansible/plugins/action/set_fact.py index 623c6be8b09..167220fe0b6 100644 --- a/lib/ansible/plugins/action/set_fact.py +++ b/lib/ansible/plugins/action/set_fact.py @@ -33,6 +33,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect facts = dict() diff --git a/lib/ansible/plugins/action/set_stats.py b/lib/ansible/plugins/action/set_stats.py index c0a55878be7..6ccb12fd76a 100644 --- a/lib/ansible/plugins/action/set_stats.py +++ b/lib/ansible/plugins/action/set_stats.py @@ -34,6 +34,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect stats = {'data': {}, 'per_host': False, 'aggregate': True} diff --git a/lib/ansible/plugins/action/shell.py b/lib/ansible/plugins/action/shell.py index da0385824bc..b2ebe174971 100644 --- a/lib/ansible/plugins/action/shell.py +++ b/lib/ansible/plugins/action/shell.py @@ -11,6 +11,8 @@ from ansible.utils.vars import merge_hash class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + # Shell module is implemented via command self._task.action = 'command' self._task.args['_uses_shell'] = True diff --git a/lib/ansible/plugins/action/sros.py b/lib/ansible/plugins/action/sros.py index ae044d636fb..3bff1b7a30d 100644 --- a/lib/ansible/plugins/action/sros.py +++ b/lib/ansible/plugins/action/sros.py @@ -37,6 +37,7 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect if self._play_context.connection == 'network_cli': provider = self._task.args.get('provider', {}) @@ -69,5 +70,5 @@ class ActionModule(_ActionModule): else: 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 diff --git a/lib/ansible/plugins/action/sros_config.py b/lib/ansible/plugins/action/sros_config.py index 1b6902ca1a2..aeb6468c9e3 100644 --- a/lib/ansible/plugins/action/sros_config.py +++ b/lib/ansible/plugins/action/sros_config.py @@ -43,6 +43,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index cac7f59c937..54b053cb0ee 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -164,6 +164,7 @@ class ActionModule(ActionBase): _tmp_args = self._task.args.copy() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect # Store remote connection type self._remote_transport = self._connection.transport diff --git a/lib/ansible/plugins/action/telnet.py b/lib/ansible/plugins/action/telnet.py index eb3883a3df4..81de2a3383a 100644 --- a/lib/ansible/plugins/action/telnet.py +++ b/lib/ansible/plugins/action/telnet.py @@ -22,6 +22,7 @@ class ActionModule(ActionBase): self._display.warning('The telnet task does not support the environment keyword') result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect if self._play_context.check_mode: # in --check mode, always skip this module execution diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index c25940a0ba4..71bcb8da9d5 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -41,8 +41,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect source = self._task.args.get('src', None) dest = self._task.args.get('dest', None) @@ -156,13 +155,13 @@ class ActionModule(ActionBase): loader=self._loader, templar=self._templar, 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: shutil.rmtree(local_tempdir) except AnsibleAction as e: result.update(e.result) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/unarchive.py b/lib/ansible/plugins/action/unarchive.py index fdcb59aef9d..e0610f93b28 100644 --- a/lib/ansible/plugins/action/unarchive.py +++ b/lib/ansible/plugins/action/unarchive.py @@ -36,8 +36,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) - - tmp = self._connection._shell.tempdir + del tmp # tmp no longer has any effect source = self._task.args.get('src', None) dest = self._task.args.get('dest', None) @@ -85,7 +84,7 @@ class ActionModule(ActionBase): if not remote_src: # 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) # handle diff mode client side @@ -93,7 +92,7 @@ class ActionModule(ActionBase): if not remote_src: # 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. new_module_args = self._task.args.copy() new_module_args.update( @@ -121,5 +120,5 @@ class ActionModule(ActionBase): except AnsibleAction as e: result.update(e.result) finally: - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/vyos.py b/lib/ansible/plugins/action/vyos.py index 965cd75cb06..5e12dffc06b 100644 --- a/lib/ansible/plugins/action/vyos.py +++ b/lib/ansible/plugins/action/vyos.py @@ -39,6 +39,8 @@ except ImportError: class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + socket_path = None if self._play_context.connection == 'network_cli': @@ -83,5 +85,5 @@ class ActionModule(_ActionModule): conn.send_command('abort') out = conn.get_prompt() - result = super(ActionModule, self).run(tmp, task_vars) + result = super(ActionModule, self).run(task_vars=task_vars) return result diff --git a/lib/ansible/plugins/action/vyos_config.py b/lib/ansible/plugins/action/vyos_config.py index f8e06862249..2c780b10de3 100644 --- a/lib/ansible/plugins/action/vyos_config.py +++ b/lib/ansible/plugins/action/vyos_config.py @@ -44,6 +44,7 @@ class ActionModule(_ActionModule): return dict(failed=True, msg=exc.message) 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__'): # User requested backup and no error occurred in module. diff --git a/lib/ansible/plugins/action/wait_for_connection.py b/lib/ansible/plugins/action/wait_for_connection.py index 46cfba5b73e..1f777e8b81d 100644 --- a/lib/ansible/plugins/action/wait_for_connection.py +++ b/lib/ansible/plugins/action/wait_for_connection.py @@ -74,6 +74,7 @@ class ActionModule(ActionBase): return dict(skipped=True) result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect def ping_module_test(connect_timeout): ''' Test ping module, if available ''' @@ -86,9 +87,9 @@ class ActionModule(ActionBase): # Use win_ping on winrm/powershell, else use ping 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: - 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 if ping_result['ping'] != 'pong': diff --git a/lib/ansible/plugins/action/win_copy.py b/lib/ansible/plugins/action/win_copy.py index b0be7ff507d..a29ef4e9e3c 100644 --- a/lib/ansible/plugins/action/win_copy.py +++ b/lib/ansible/plugins/action/win_copy.py @@ -281,8 +281,7 @@ class ActionModule(ActionBase): copy_result = self._execute_module(module_name="copy", module_args=copy_args, - task_vars=task_vars, - tmp=tmp) + task_vars=task_vars) return copy_result @@ -325,8 +324,7 @@ class ActionModule(ActionBase): module_return = self._execute_module(module_name='copy', module_args=copy_args, - task_vars=task_vars, - tmp=tmp) + task_vars=task_vars) os.removedirs(os.path.dirname(zip_path)) return module_return @@ -336,6 +334,7 @@ class ActionModule(ActionBase): task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect source = self._task.args.get('src', None) content = self._task.args.get('content', None) @@ -482,22 +481,21 @@ class ActionModule(ActionBase): query_args.pop('content', None) query_return = self._execute_module(module_args=query_args, - task_vars=task_vars, - tmp=tmp) + task_vars=task_vars) if query_return.get('failed') is True: result.update(query_return) return result - if len(query_return['files']) > 0 or len(query_return['directories']) > 0 and tmp is None: - tmp = self._make_tmp_path() + if len(query_return['files']) > 0 or len(query_return['directories']) > 0 and self._connection._shell.tempdir is None: + self._connection._shell.tempdir = self._make_tmp_path() 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 file_src = query_return['files'][0]['src'] file_dest = query_return['files'][0]['dest'] copy_result = self._copy_single_file(file_src, dest, file_dest, - task_vars, tmp) + task_vars, self._connection._shell.tempdir) result['changed'] = True if copy_result.get('failed') is True: @@ -509,7 +507,7 @@ class ActionModule(ActionBase): # TODO: handle symlinks result.update(self._copy_zip_file(dest, source_files['files'], source_files['directories'], - task_vars, tmp)) + task_vars, self._connection._shell.tempdir)) result['changed'] = True else: # 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 self._remove_tempfile_if_content_defined(content, content_tempfile) - self._remove_tmp_path(tmp) + self._remove_tmp_path(self._connection._shell.tempdir) return result diff --git a/lib/ansible/plugins/action/win_reboot.py b/lib/ansible/plugins/action/win_reboot.py index e2f231eee53..eccce679a10 100644 --- a/lib/ansible/plugins/action/win_reboot.py +++ b/lib/ansible/plugins/action/win_reboot.py @@ -73,6 +73,7 @@ class ActionModule(ActionBase): task_vars = dict() 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): return result diff --git a/lib/ansible/plugins/action/win_updates.py b/lib/ansible/plugins/action/win_updates.py index 4ee48f056d7..ad6d1ad0012 100644 --- a/lib/ansible/plugins/action/win_updates.py +++ b/lib/ansible/plugins/action/win_updates.py @@ -133,6 +133,7 @@ class ActionModule(ActionBase): self._supports_async = True result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect category_names = self._task.args.get('category_names', [ 'CriticalUpdates',