Conflicting Modules

Hello guys,

Let’s suppose that 2 different modules with the same name exist on Ansible 2.0.0.2:

  • one as a core module
  • one as an imported module into /usr/share/ansible

Which one gets precedence by default when a call is made and how can we specifically choose one over the other one?

First, /usr/share/ansible is normally where core modules are stored, so not sure what you are asking, but let me explain how loading works.

If you put a module in a library dir adjacent to a play or in a role with the same name as a ‘core’ module, it will override it, if that is what you are asking.

also the module path (settable in ansible.cfg or by env var) can be used to establish priority, first found will override others, so if you set a custom path before the ones shipped with ansible, they will be loaded first and override them.

Thanks for your answer.
I have a /usr/share/ansible/cisco_nxos/library folder which contains many modules. Calling them works fine.
However, some new Cisco network modules are currently being incorporated as core modules into ansible (http://docs.ansible.com/ansible/list_of_network_modules.html#nxos), so some overlap is about to happen.

There is a “library = /usr/share/ansible” within /etc/ansible/ansible.cfg. Are you suggesting that we can have multiple “library = …” settings, which would allow me to move the external library into another user folder and set some priority between them that way?

Actually, there is no Ansible core modules in /usr/share/ansible: they are located in “/usr/lib/pymodules/python2.7/ansible/modules”.
Since there is only one global “library” variable in /etc/ansible/ansible.cfg, and considering the fact that it is set to /usr/share/ansible by default, without any detailed documentation on that matter, my guess is that:

  • ansible core modules have the highest priority
  • it is not possible to establish some priority amongst different libraries with the ansible config file
  • we should avoid same module names among different libraries since we don’t know how Ansible would behave
    … unless someone has an official answer.