Interview Prep/Ansible/Roles, Collections and Project Structure

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.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure