How do role dependencies work?
IntermediateConceptRoles, Collections and Galaxy
Answer
List them in meta/main.yml. Ansible runs dependencies before the role itself, in order.
# roles/app/meta/main.yml
dependencies:
- role: common
- role: java
java_version: 17
Dependencies can pass parameters and are installed by ansible-galaxy when listed there with a source. Keep dependency chains shallow: hidden implicit roles make a play hard to reason about, so many teams prefer explicit ordering in the playbook.
More on Roles, Collections and Galaxy
What is a role and why use one?BeginnerWhat is the standard role directory structure?BeginnerHow do you scaffold a new role?BeginnerWhat are the ways to use a role in a play?IntermediateIf a role is included twice in a play, does it run twice?AdvancedHow do you pass parameters to a role?Intermediate