Interview Prep/Ansible/Roles, Collections and Galaxy

An outdated copy of the `common` role runs instead of the one in the repo

AdvancedTroubleshootingRoles, Collections and Galaxy
Answer

Likely causes → Roles are found by name, and the first match wins. If the playbook moved and the project's roles/ is no longer next to it, or roles_path lists ~/.ansible/roles first, a stale common installed months ago shadows the repo copy.

Diagnose →

- ansible.builtin.debug:
    var: role_path        # inside the role: shows which copy is used

ls ~/.ansible/roles /etc/ansible/roles for leftover copies.

Fix → Remove the stale copies, put the project's role directories first in roles_path, and give internal roles unique names, or better, ship them in a collection (acme.platform.common) so the FQCN removes the ambiguity.

Prevent → Run CI in clean containers or execution environments with no user-level role directories.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Galaxy