Ansible Project Structure

Standard Ansible project layout with 21 explained components: inventory (production/staging), group_vars (all.yml/webservers.yml), host_vars (server1.yml), roles (common/webserver/database), playbooks (site.yml/web.yml/db.yml), templates (Jinja2), files (static assets), ansible.cfg, requirements.yml.

Overview

Ansible project layout

A well-structured Ansible project is self-documenting, easy to test, and scales to hundreds of hosts without becoming unmanageable. The standard layout separates concerns: inventory (where), variables (what values), roles (how) and playbooks (when and for whom).

The rest of this introduction walks the layout in that order.

Key concepts

  • Variable precedence
  • ansible.cfg
  • Jinja2 templates
  • Dynamic inventory
  • requirements.yml

Interview questions

  • Explain Ansible variable precedence and where you would define each type of variable.

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio