Interview Prep/Ansible/Project Structure and Design

What does a production Ansible repository look like?

BeginnerProductionProject Structure and Design
Answer

In production we keep one repo with a predictable layout, so anyone on the team can find things in seconds.

infra-ansible/
  ansible.cfg
  requirements.yml            # pinned collections and roles
  inventories/
    dev/   { aws_ec2.yml, group_vars/, host_vars/ }
    stage/ { ... }
    prod/  { ... }
  playbooks/
    site.yml  web.yml  db.yml  patch.yml  deploy.yml
  roles/                      # our own roles
  collections/                # installed deps (git-ignored)
  .ansible-lint  .yamllint  .pre-commit-config.yaml

Environments differ by inventory directory, never by forked copies of playbooks.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design