Interview Prep/Ansible/Roles, Collections and Project Structure

You want to share roles across several repos and teams.

IntermediateScenarioRoles, Collections and Project Structure
Answer

Situation read → Distribution and versioning.

What I'd do →

  1. Package roles in a collection (namespace.collection) or keep one repo per role.
  2. Pin versions in requirements.yml.
collections:
  - name: acme.platform
    version: 1.4.2
    source: https://galaxy.internal.example.com
roles:
  - src: git+https://git.example.com/ansible/nginx.git
    version: v2.1.0
    name: acme.nginx

Install with ansible-galaxy install -r requirements.yml.

Why → Pinned versions give reproducible builds.

Interview tip → Use a private Galaxy/Automation Hub or Artifactory for internal content.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure