From 21157aa1bca63f194fbd382f20ee6d23d3acbfb8 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 9 Feb 2017 14:26:09 -0500 Subject: [PATCH] loads action handler for a group of network modules (#21194) * loads action handler based on module group prefix for network modules --- lib/ansible/executor/task_executor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index c211a5b6b1..f0500e1b5f 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -758,9 +758,14 @@ class TaskExecutor: Returns the correct action plugin to handle the requestion task action ''' + network_group_modules = frozenset(['eos', 'nxos', 'ios', 'iosxr', 'junos', 'vyos']) + module_prefix = self._task.action.split('_')[0] + # let action plugin override module, fallback to 'normal' action plugin otherwise if self._task.action in self._shared_loader_obj.action_loader: handler_name = self._task.action + elif all((module_prefix in network_group_modules, module_prefix in self._shared_loader_obj.action_loader)): + handler_name = module_prefix else: pc_conn = self._shared_loader_obj.connection_loader.get(self._play_context.connection, class_only=True) handler_name = getattr(pc_conn, 'action_handler', 'normal')