Interview Prep/Ansible/Roles, Collections and Project Structure

Roles in your repo access each other's internal variables. How do you reduce coupling?

IntermediateScenarioRoles, Collections and Project Structure
Answer

Situation read → Tight coupling.

What I'd do →

  1. Define a clear public interface in defaults/ and argument_specs.
  2. Pass data in via role parameters, not by reading another role's vars.
  3. Share common facts via a common role or inventory variables.

Why → Roles that only depend on declared inputs are replaceable and testable alone.

Interview tip → Say "a role is a function: inputs in defaults, effects on the host".

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure