Interview Prep/Ansible/Roles, Collections and Galaxy

A role listed in `meta/main.yml` dependencies runs only once, even though two roles need it with different parameters

IntermediateTroubleshootingRoles, Collections and Galaxy
Answer

Likely causes → Ansible deduplicates role dependencies. A role runs once per play unless it is called with different parameters or the role sets allow_duplicates: true. The opposite surprise also happens: a dependency runs twice because its parameters differ slightly.

Fix → If running it several times is intended, add this to the dependency role:

# roles/firewall_rule/meta/main.yml
allow_duplicates: true

Otherwise, call it explicitly with include_role where it is needed.

Prevent → Keep meta dependencies for true prerequisites. Make orchestration visible in the playbook instead of hiding it in dependency chains.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Galaxy