diff --git a/changelogs/fragments/improve-tombstone-error.yml b/changelogs/fragments/improve-tombstone-error.yml new file mode 100644 index 00000000000..faee68b083d --- /dev/null +++ b/changelogs/fragments/improve-tombstone-error.yml @@ -0,0 +1,3 @@ +bugfixes: + - Include the task location when a module or action plugin is deprecated (https://github.com/ansible/ansible/issues/82450). + - Give the tombstone error for ``include`` pre-fork like other tombstoned action/module plugins. diff --git a/lib/ansible/parsing/mod_args.py b/lib/ansible/parsing/mod_args.py index 9da6f83e211..2e024f0a446 100644 --- a/lib/ansible/parsing/mod_args.py +++ b/lib/ansible/parsing/mod_args.py @@ -46,7 +46,6 @@ RAW_PARAM_MODULES = FREEFORM_ACTIONS.union(add_internal_fqcns(( BUILTIN_TASKS = frozenset(add_internal_fqcns(( 'meta', - 'include', 'include_tasks', 'include_role', 'import_tasks', @@ -302,9 +301,14 @@ class ModuleArgsParser: elif skip_action_validation: is_action_candidate = True else: - context = action_loader.find_plugin_with_context(item, collection_list=self._collection_list) - if not context.resolved: - context = module_loader.find_plugin_with_context(item, collection_list=self._collection_list) + try: + context = action_loader.find_plugin_with_context(item, collection_list=self._collection_list) + if not context.resolved: + context = module_loader.find_plugin_with_context(item, collection_list=self._collection_list) + except AnsibleError as e: + if e.obj is None: + e.obj = self._task_ds + raise e is_action_candidate = context.resolved and bool(context.redirect_list) diff --git a/test/integration/targets/collections/runme.sh b/test/integration/targets/collections/runme.sh index 35607088b8d..be762f8decf 100755 --- a/test/integration/targets/collections/runme.sh +++ b/test/integration/targets/collections/runme.sh @@ -151,3 +151,12 @@ fi ./vars_plugin_tests.sh ./test_task_resolved_plugin.sh + +# Test tombstoned module/action plugins include the location of the fatal task +cat < test_dead_ping_error.yml +- hosts: localhost + gather_facts: no + tasks: + - dead_ping: +EOF +ansible-playbook test_dead_ping_error.yml 2>&1 >/dev/null | grep -e 'line 4, column 5' diff --git a/test/units/playbook/test_included_file.py b/test/units/playbook/test_included_file.py index cbefe2f7c02..7d1e7079fc1 100644 --- a/test/units/playbook/test_included_file.py +++ b/test/units/playbook/test_included_file.py @@ -315,9 +315,6 @@ def test_empty_raw_params(): parent_task._play = None task_ds_list = [ - { - 'include': '' - }, { 'include_tasks': '' },