fix module_defaults group incorrectly giving deprecation warnings (#83510)

don't display deprecation warnings for actions/modules as a result of using an action_group containing a deprecated plugin
pull/83687/head
Sloane Hertel 4 months ago committed by GitHub
parent d23a2de5f2
commit ff5deaf62f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- module_defaults - do not display action/module deprecation warnings when using an action_group that contains a deprecated plugin (https://github.com/ansible/ansible/issues/83490).

@ -386,13 +386,13 @@ class FieldAttributeBase:
return fq_group_name, resolved_actions return fq_group_name, resolved_actions
def _resolve_action(self, action_name, mandatory=True): def _resolve_action(self, action_name, mandatory=True):
context = module_loader.find_plugin_with_context(action_name) context = module_loader.find_plugin_with_context(action_name, ignore_deprecated=(not mandatory))
if context.resolved and not context.action_plugin: if context.resolved and not context.action_plugin:
prefer = action_loader.find_plugin_with_context(action_name) prefer = action_loader.find_plugin_with_context(action_name, ignore_deprecated=(not mandatory))
if prefer.resolved: if prefer.resolved:
context = prefer context = prefer
elif not context.resolved: elif not context.resolved:
context = action_loader.find_plugin_with_context(action_name) context = action_loader.find_plugin_with_context(action_name, ignore_deprecated=(not mandatory))
if context.resolved: if context.resolved:
return context.resolved_fqcn return context.resolved_fqcn

@ -44,12 +44,19 @@ plugin_routing:
ios_facts: ios_facts:
action_plugin: testns.testcoll.redirected_action action_plugin: testns.testcoll.redirected_action
old_ping:
deprecation:
removal_date: 2020-12-31
warning_text: old_ping will be removed in a future release of this collection. Use ping instead.
redirect: ping
action_groups: action_groups:
testgroup: testgroup:
# Test metadata 'extend_group' feature does not get stuck in a recursive loop # Test metadata 'extend_group' feature does not get stuck in a recursive loop
- metadata: - metadata:
extend_group: othergroup extend_group: othergroup
- metadata - metadata
- old_ping
- ping - ping
- testns.testcoll.echo1 - testns.testcoll.echo1
- testns.testcoll.echo2 - testns.testcoll.echo2

@ -5,7 +5,8 @@ set -eux
# Symlink is test for backwards-compat (only workaround for https://github.com/ansible/ansible/issues/77059) # Symlink is test for backwards-compat (only workaround for https://github.com/ansible/ansible/issues/77059)
sudo ln -s "${PWD}/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py" ./collections/ansible_collections/testns/testcoll/plugins/action/vyosfacts.py sudo ln -s "${PWD}/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py" ./collections/ansible_collections/testns/testcoll/plugins/action/vyosfacts.py
ansible-playbook test_defaults.yml "$@" ANSIBLE_DEPRECATION_WARNINGS=true ansible-playbook test_defaults.yml "$@" 2> err.txt
test "$(grep -c 'testns.testcoll.old_ping has been deprecated' err.txt || 0)" -eq 0
sudo rm ./collections/ansible_collections/testns/testcoll/plugins/action/vyosfacts.py sudo rm ./collections/ansible_collections/testns/testcoll/plugins/action/vyosfacts.py

Loading…
Cancel
Save