Ansible Core has a setup.py module for Unix systems (https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/setup.py). This is responsible for "fact gathering".
Ansible Windows has a setup.ps1 module for Windows systems and mimics the behaviour in setup.py to some extent (https://github.com/ansible-collections/ansible.windows/blob/main/plugins/modules/setup.ps1).
When running:
- name: Setup
setup:
Ansible correctly identifies which module to run.
My question is, how does Ansible determine which module to run?
I cannot find any action plugins that would be called beforehand that would determine which module to run.
Furthermore, when I attempt to mimic this behvaiour with a custom module I receive errors when running with Unix. This is because it attempts to run the .ps1 version of the module rather than the .py version.
I found the answer.
Under the collection you can create a
meta/runtime.ymlfile in which you define:This then allows you to ues
[module_name]and Ansible will determine where to look for the.ps1variant of that module.