Two roles need to run in a fixed order, such as `common` before `nginx`.
BeginnerScenarioRoles, Collections and Project Structure
Answer
Situation read → Dependency between roles.
What I'd do → Declare it in meta/main.yml.
# roles/nginx/meta/main.yml
dependencies:
- role: common
Why → Dependencies run first, and by default only once per play even if several roles list them.
Interview tip → Prefer explicit ordering in the playbook when the dependency is policy rather than a hard requirement.
More on Roles, Collections and Project Structure
You have a 600-line playbook that sets up web, db and monitoring. How do you restructure it?BeginnerWhere do you put a variable users of your role are expected to override?BeginnerA role is used twice with different parameters in one play, but only runs once.IntermediateYou want to share roles across several repos and teams.IntermediateHow do you pin Ansible itself so a CI run today behaves like one last month?IntermediateA role installs a package and writes a config, but must support Ubuntu and Rocky Linux.Intermediate