Ansible 2.9.4 collection not picking the action plugin

12 views
Skip to first unread message

Mohamed Javeed

unread,
Feb 21, 2020, 8:30:54 AM2/21/20
to Ansible Development

Hi  team,


I’m having trouble getting the actions plugin inside the collection being used on playbook execution


This happens due to the name change from dellos10.py to os10.py for the plugin

 

Summary of issue

====================

Action Plugin in collection: /root/.ansible/collections/ansible_collections/dellemc_networking/os10/plugins/action/os10.py

Roles Task yaml referring module: /root/.ansible/collections/ansible_collections/dellemc_networking/os10/roles/os10_vlan/tasks/provision_os10.yaml

 

- name: "Provisioning VLAN configuration for os10"

   os10_config:

      src: os10_vlan.j2

   when: (ansible_network_os is defined and ansible_network_os == "dellemc_networking.os10.os10")

#   notify: save config os10

   register: output

 

When a playbook referring role os10_vlan is getting executed, the Action plugin os10.py is not being loaded. Only the ‘normal’ action plugin got loaded and eventually, the playbook failed.

 

Root cause:

==========

In Ansible(2.9.4),  file: lib/ansible/executor/task_executor.py Function: _get_action_handler

We have the following code that loads the appropriate Action plugin for the module used in the playbook(os10_config)

module_prefix = self._task.action.split('.')[-1].split('_')[0]

collections = self._task.collections

 

if self._shared_loader_obj.action_loader.has_plugin(self._task.action, collection_list=collections):

            handler_name = self._task.action

        # FIXME: is this code path even live anymore? check w/ networking folks; it trips sometimes when it shouldn't

elif all((module_prefix in C.NETWORK_GROUP_MODULES, module_prefix in self._shared_loader_obj.action_loader)):

            handler_name = module_prefix

else:

            # FUTURE: once we're comfortable with collections impl, preface this action with ansible.builtin so it can't be hijacked

            handler_name = 'normal'

            collections = None  # until then, we don't want the task's collection list to be consulted; use the builtin

 

The first IF statement, checks for a Action plugin with the same name as module name(os0_config) in the collection. This IF check fails ,since our plugin is ‘os10’ and not ‘os10_config’

The second ELIF statement, checks if the module prefix(‘os10’) is part of NETWORK_GROUP_MODULES and if so, searches it for Action plugin in collections.

The Ansible maintains only the following list of prefixes in NETWORK_GROUP_MODULES by default.Since ‘os10’ prefix is not part of this list,

the ELIF check also fails. Eventually we end up loading ‘normal’ plugin.

 

File: : lib/ansible/config/base.yml

NETWORK_GROUP_MODULES:

  name: Network module families

  default: [eos, nxos, ios, iosxr, junos, enos, ce, vyos, sros, dellos9, dellos10, dellos6, asa, aruba, aireos, bigip, ironware, onyy

x, netconf]

  description: 'TODO: write it'

 

Fix:

====

export ANSIBLE_NETWORK_GROUP_MODULES=os10


Is this the right way to handle this?


Thanks

Mohamed Javeed


Reply all
Reply to author
Forward
0 new messages