[stable-2.19] Short-circuit legacy network module prefix->action mapping (#85406) (#85413)

* Short-circuit legacy network module prefix->action mapping

* Modified a non-short-circuit compound conditional in a legacy networking path that attempted to resolve an action for any module name containing `_`. The bug was always present, but the typical presentation (an ImportError) was ignored prior to 2.19.
* The legacy networking path should be deprecated and removed in 2.20- a module could still be run under the wrong action if one with a matching prefix is found.

* unit test fix
(cherry picked from commit d6efb7db8a)

Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>
pull/85452/head
Matt Clay 5 months ago committed by GitHub
parent da732a5c3c
commit 100b20260a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1129,7 +1129,7 @@ class TaskExecutor:
# let action plugin override module, fallback to 'normal' action plugin otherwise # let action plugin override module, fallback to 'normal' action plugin otherwise
elif self._shared_loader_obj.action_loader.has_plugin(self._task.action, collection_list=collections): elif self._shared_loader_obj.action_loader.has_plugin(self._task.action, collection_list=collections):
handler_name = self._task.action handler_name = self._task.action
elif all((module_prefix in C.NETWORK_GROUP_MODULES, self._shared_loader_obj.action_loader.has_plugin(network_action, collection_list=collections))): elif module_prefix in C.NETWORK_GROUP_MODULES and self._shared_loader_obj.action_loader.has_plugin(network_action, collection_list=collections):
handler_name = network_action handler_name = network_action
display.vvvv("Using network group action {handler} for {action}".format(handler=handler_name, display.vvvv("Using network group action {handler} for {action}".format(handler=handler_name,
action=self._task.action), action=self._task.action),

@ -273,8 +273,7 @@ class TestTaskExecutor(unittest.TestCase):
self.assertIs(mock.sentinel.handler, handler) self.assertIs(mock.sentinel.handler, handler)
action_loader.has_plugin.assert_has_calls([mock.call(action, collection_list=te._task.collections), action_loader.has_plugin.assert_has_calls([mock.call(action, collection_list=te._task.collections)])
mock.call(module_prefix, collection_list=te._task.collections)])
action_loader.get.assert_called_with( action_loader.get.assert_called_with(
'ansible.legacy.normal', task=te._task, connection=te._connection, 'ansible.legacy.normal', task=te._task, connection=te._connection,

Loading…
Cancel
Save