Interview Prep/Ansible/Roles, Collections and Project Structure

You have to ship a custom module and filter with your role.

AdvancedScenarioRoles, Collections and Project Structure
Answer

Situation read → Role-local plugins.

What I'd do → Put them in the role: roles/myrole/library/my_module.py, roles/myrole/filter_plugins/my_filters.py. They become available to that role and anything after it in the play.

For wider reuse, put them in a collection under plugins/modules and plugins/filter, then call them by FQCN.

Why → Collections give namespacing, versioning and documentation hooks.

Interview tip → Mention ansible-doc and DOCUMENTATION strings for modules.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure