Architect the Project: Roles & Inventory
Lay out the full deployment repo.
Architect the Project: Roles & Inventory is a free Ansible Academy lesson on CoddyKit. This is lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, and your progress syncs across the web and the CoddyKit app. The Ansible Academy course includes 4 lessons in total.
The Capstone Goal
Time to ship a real multi-tier app with a rolling deploy and zero downtime. First step: design the project layout. 🚀
Think in Roles
Break the system into roles: one per concern like common, web, app, db and loadbalancer. Each is reusable and testable on its own.
The Top-Level Layout
A clean repo keeps inventory, group_vars, roles and a site.yml entry playbook at the root, so anyone can find things fast.
deploy/
site.yml
inventory/
group_vars/
host_vars/
roles/site.yml Ties It Together
Your master playbook site.yml imports per-tier plays in order. It is the single command that deploys the whole stack.
- import_playbook: plays/loadbalancer.yml
- import_playbook: plays/db.yml
- import_playbook: plays/app.yml
- import_playbook: plays/web.ymlMap Tiers to Groups
Your inventory defines a group per tier: lb, db, app and web. Each play targets exactly the hosts it owns.
[lb]
lb1
[web]
web1
web2
[app]
app1
app2
[db]
db1group_vars per Tier
Store tier settings in group_vars: web ports, app version, db credentials. Hosts inherit them automatically, no copy-paste.
group_vars/web.yml:
nginx_port: 80
upstream: app:8080host_vars for Specials
When one host differs, put overrides in host_vars. The primary db, for example, may carry replication settings the rest lack.
host_vars/db1.yml:
postgresql_role: primaryPin the App Version
Make the release version a variable, not a hardcoded string. One change point lets you roll forward or back in seconds.
group_vars/all.yml:
app_version: "2.4.1"Separate Environments
Keep inventory folders per environment so staging and production never share hosts. Same roles, different targets.
inventory/
staging/hosts
production/hostsLock Your Dependencies
List external Galaxy roles in requirements.yml so every teammate and CI run installs the exact same automation code.
roles:
- name: geerlingguy.nginx
version: 3.1.4Architecture First Pays Off
A thoughtful layout turns a scary deploy into a few predictable commands. Structure now saves you firefighting later. 🧱
Quick Check
Let us place one piece of config correctly.
Recap
You designed the repo: roles per tier, inventory groups, group_vars and host_vars, and a site.yml that runs the whole deploy. ✅
Frequently Asked Questions
Is the “Architect the Project: Roles & Inventory” lesson free?
Yes — the full text of “Architect the Project: Roles & Inventory” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO. The Ansible Academy course includes 4 lessons in total.
What will I learn in “Architect the Project: Roles & Inventory”?
Lay out the full deployment repo. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ansible Academy?
No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 4.
How long does the “Architect the Project: Roles & Inventory” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ansible Academy lesson?
Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Architect the Project: Roles & Inventory
- Provision, Harden & Bootstrap Hosts
- Rolling Deploy Behind the Load Balancer
- Smoke Tests, Rollback & Notifications