diff --git a/lib/ansible/parsing/mod_args.py b/lib/ansible/parsing/mod_args.py index bf8275b69fa..cfa9574ede4 100644 --- a/lib/ansible/parsing/mod_args.py +++ b/lib/ansible/parsing/mod_args.py @@ -29,9 +29,7 @@ from ansible.utils.sentinel import Sentinel # modules formated for user msg -FREEFORM_ACTIONS_SIMPLE = set(C.MODULE_REQUIRE_ARGS_SIMPLE) -FREEFORM_ACTIONS = frozenset(add_internal_fqcns(FREEFORM_ACTIONS_SIMPLE)) -RAW_PARAM_MODULES = FREEFORM_ACTIONS_SIMPLE.union(set([ +_BUILTIN_RAW_PARAM_MODULES_SIMPLE = set([ 'include_vars', 'include_tasks', 'include_role', @@ -41,9 +39,12 @@ RAW_PARAM_MODULES = FREEFORM_ACTIONS_SIMPLE.union(set([ 'group_by', 'set_fact', 'meta', -])) +]) +FREEFORM_ACTIONS_SIMPLE = set(C.MODULE_REQUIRE_ARGS_SIMPLE) +FREEFORM_ACTIONS = frozenset(C.MODULE_REQUIRE_ARGS) +RAW_PARAM_MODULES_SIMPLE = _BUILTIN_RAW_PARAM_MODULES_SIMPLE.union(FREEFORM_ACTIONS_SIMPLE) # For filtering out modules correctly below, use all permutations -RAW_PARAM_MODULES_MATCH = add_internal_fqcns(RAW_PARAM_MODULES) + C.WIN_MOVED +RAW_PARAM_MODULES = frozenset(add_internal_fqcns(RAW_PARAM_MODULES_SIMPLE)).union(FREEFORM_ACTIONS) BUILTIN_TASKS = frozenset(add_internal_fqcns(( 'meta', 'include_tasks', @@ -352,14 +353,14 @@ class ModuleArgsParser: else: raise AnsibleParserError("no module/action detected in task.", obj=self._task_ds) - elif args.get('_raw_params', '') != '' and action not in RAW_PARAM_MODULES_MATCH: + elif args.get('_raw_params', '') != '' and action not in RAW_PARAM_MODULES: templar = Templar(loader=None) raw_params = args.pop('_raw_params') if templar.is_template(raw_params): args['_variable_params'] = raw_params else: - raise AnsibleParserError("this task '%s' has extra params, which is only allowed in the following modules: %s" % (action, - ", ".join(RAW_PARAM_MODULES)), - obj=self._task_ds) + raise AnsibleParserError( + "this task '%s' has extra params, which is only allowed in the following modules: %s" % (action, ", ".join(RAW_PARAM_MODULES_SIMPLE)), + obj=self._task_ds) return (action, args, delegate_to) diff --git a/test/integration/targets/windows-minimal/tasks/main.yml b/test/integration/targets/windows-minimal/tasks/main.yml index a7e6ba7fc4e..1e075d7a61b 100644 --- a/test/integration/targets/windows-minimal/tasks/main.yml +++ b/test/integration/targets/windows-minimal/tasks/main.yml @@ -65,3 +65,23 @@ - win_ping_crash_result is not changed - 'win_ping_crash_result.msg == "Unhandled exception while executing module: boom"' - '"throw \"boom\"" in win_ping_crash_result.exception' + +- name: verify that shortname _raw_params works + win_shell: echo "name=foo" + register: win_shell_short_res + failed_when: win_shell_short_res.stdout | trim != 'name=foo' + +- name: verify that legacy _raw_params works + ansible.legacy.win_shell: echo "name=foo" + register: win_shell_legacy_res + failed_when: win_shell_legacy_res.stdout | trim != 'name=foo' + +- name: verify that builtin _raw_params works + ansible.builtin.win_shell: echo "name=foo" + register: win_shell_builtin_res + failed_when: win_shell_builtin_res.stdout | trim != 'name=foo' + +- name: verify that collection _raw_params works + ansible.windows.win_shell: echo "name=foo" + register: win_shell_collection_res + failed_when: win_shell_collection_res.stdout | trim != 'name=foo'