Skip to content

Commit

Permalink
Add the task info for tombstoned module/action plugins (#82451) (#83040)
Browse files Browse the repository at this point in the history
* Add the task info for tombstoned plugins

* Fix deprecation for 'include' by removing it from BUILTIN_TASKS which skip the plugin loader lookup

* changelog

remove obsolete unit test using 'include'

* Update changelogs/fragments/improve-tombstone-error.yml

(cherry picked from commit caa86cc)
  • Loading branch information
s-hertel committed May 9, 2024
1 parent 2809218 commit 59c5f77
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/improve-tombstone-error.yml
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 8 additions & 4 deletions lib/ansible/parsing/mod_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

BUILTIN_TASKS = frozenset(add_internal_fqcns((
'meta',
'include',
'include_tasks',
'include_role',
'import_tasks',
Expand Down Expand Up @@ -304,9 +303,14 @@ def parse(self, skip_action_validation=False):
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)

Expand Down
9 changes: 9 additions & 0 deletions test/integration/targets/collections/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,12 @@ fi
./vars_plugin_tests.sh

./test_task_resolved_plugin.sh

# Test tombstoned module/action plugins include the location of the fatal task
cat <<EOF > 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'
3 changes: 0 additions & 3 deletions test/units/playbook/test_included_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ def test_empty_raw_params():
parent_task._play = None

task_ds_list = [
{
'include': ''
},
{
'include_tasks': ''
},
Expand Down

0 comments on commit 59c5f77

Please sign in to comment.