Using role dependencies
Role dependencies let you automatically pull in other roles when using a role.
Role dependencies are prerequisites, not true dependencies. The roles do not have a parent/child relationship. Ansible loads all listed roles, runs the roles listed underdependenciesfirst, then runs the role that lists them. The play object is the parent of all roles, including roles called by adependencieslist.
Role dependencies are stored in themeta/main.ymlfile within the role directory. This file should contain a list of roles and parameters to insert before the specified role. For example:
Ansible always executes roles listed independenciesbefore the role that lists them. Ansible executes this pattern recursively when you use theroleskeyword. For example, if you list rolefoounderroles:, rolefoolists rolebarunderdependenciesin its meta/main.yml file, and rolebarlists rolebazunderdependenciesin its meta/main.yml, Ansible executesbaz, thenbar, thenfoo.