Ansible Create Custom Module

Hi All,

I’m trying to create an custom module to execute some REST calls (I’m aware about uri module which already exists). I have created the module now I’m trying to execute the playbook with my custom module. I placed it under the modules folder.
my folder structure is like
ansible

  • playbook.yaml

__modules

  • custon_module.py

__module_utils

  • decoder.py

but when i execute the playbook I get an error for the task which i have used the custom_module. then i changed the structure and added a new directory named library to the ansible folder and moved the custon_module.py file in to library folder. there after the playbook.yaml seems to be working fine. Anyone know the reason for this behavior ? Is there any thing else I need to do in order to place the custom_module.py in the modules folder.

Thanks you.

The reason is because “library” is the place for all custom modules, not “modules”.