core: raw params better error msg (#83726)

* less confusing error msg
* also remove 'removed' include
pull/78142/merge
Brian Coca 4 months ago committed by GitHub
parent c5210ad3eb
commit 885e3766a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- the raw arguments error now just displays the short names of modules instead of every possible variation

@ -176,10 +176,10 @@ INTERNAL_STATIC_VARS = frozenset(
] ]
) )
LOCALHOST = ('127.0.0.1', 'localhost', '::1') LOCALHOST = ('127.0.0.1', 'localhost', '::1')
MODULE_REQUIRE_ARGS = tuple(add_internal_fqcns(('command', 'win_command', 'ansible.windows.win_command', 'shell', 'win_shell', WIN_MOVED = ['ansible.windows.win_command', 'ansible.windows.win_shell']
'ansible.windows.win_shell', 'raw', 'script'))) MODULE_REQUIRE_ARGS_SIMPLE = ['command', 'raw', 'script', 'shell', 'win_command', 'win_shell']
MODULE_NO_JSON = tuple(add_internal_fqcns(('command', 'win_command', 'ansible.windows.win_command', 'shell', 'win_shell', MODULE_REQUIRE_ARGS = tuple(add_internal_fqcns(MODULE_REQUIRE_ARGS_SIMPLE) + WIN_MOVED)
'ansible.windows.win_shell', 'raw'))) MODULE_NO_JSON = tuple(add_internal_fqcns(('command', 'win_command', 'shell', 'win_shell', 'raw')) + WIN_MOVED)
RESTRICTED_RESULT_KEYS = ('ansible_rsync_path', 'ansible_playbook_python', 'ansible_facts') RESTRICTED_RESULT_KEYS = ('ansible_rsync_path', 'ansible_playbook_python', 'ansible_facts')
SYNTHETIC_COLLECTIONS = ('ansible.builtin', 'ansible.legacy') SYNTHETIC_COLLECTIONS = ('ansible.builtin', 'ansible.legacy')
TREE_DIR = None TREE_DIR = None

@ -28,11 +28,9 @@ from ansible.utils.fqcn import add_internal_fqcns
from ansible.utils.sentinel import Sentinel from ansible.utils.sentinel import Sentinel
# For filtering out modules correctly below # modules formated for user msg
FREEFORM_ACTIONS = frozenset(C.MODULE_REQUIRE_ARGS) FREEFORM_ACTIONS = set(C.MODULE_REQUIRE_ARGS_SIMPLE)
RAW_PARAM_MODULES = FREEFORM_ACTIONS.union(set([
RAW_PARAM_MODULES = FREEFORM_ACTIONS.union(add_internal_fqcns((
'include',
'include_vars', 'include_vars',
'include_tasks', 'include_tasks',
'include_role', 'include_role',
@ -42,8 +40,9 @@ RAW_PARAM_MODULES = FREEFORM_ACTIONS.union(add_internal_fqcns((
'group_by', 'group_by',
'set_fact', 'set_fact',
'meta', 'meta',
))) ]))
# For filtering out modules correctly below, use all permutations
RAW_PARAM_MODULES_MATCH = add_internal_fqcns(RAW_PARAM_MODULES) + C.WIN_MOVED
BUILTIN_TASKS = frozenset(add_internal_fqcns(( BUILTIN_TASKS = frozenset(add_internal_fqcns((
'meta', 'meta',
'include_tasks', 'include_tasks',
@ -352,7 +351,7 @@ class ModuleArgsParser:
else: else:
raise AnsibleParserError("no module/action detected in task.", raise AnsibleParserError("no module/action detected in task.",
obj=self._task_ds) obj=self._task_ds)
elif args.get('_raw_params', '') != '' and action not in RAW_PARAM_MODULES: elif args.get('_raw_params', '') != '' and action not in RAW_PARAM_MODULES_MATCH:
templar = Templar(loader=None) templar = Templar(loader=None)
raw_params = args.pop('_raw_params') raw_params = args.pop('_raw_params')
if templar.is_template(raw_params): if templar.is_template(raw_params):

Loading…
Cancel
Save