Grouping Hosts: web, db & app
Organize servers into logical groups.
Grouping Hosts: web, db & app is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
Why Group Hosts
A group lets you act on many servers at once. Instead of naming each host, you target the role they share.
Name Groups by Role
Good group names describe a server's job: web, db, app. The name becomes how you target that tier in commands.
[web]
[db]
[app]Fill the web Group
List your front-end servers under the [web] header. Now any command aimed at web hits both of them.
[web]
web1.example.com
web2.example.comAdd a db Group
Group your database hosts under [db]. Keeping tiers separate means a risky db task never touches a web box.
[db]
db1.example.comTarget One Group
Pass a group name where you would name a host. Here Ansible pings only the db tier and ignores the rest.
ansible db -i inventory.ini -m pingA Host Can Join Many Groups
List the same host under two headers and it belongs to both groups. Handy for a box that runs app and web together.
[web]
node1.example.com
[app]
node1.example.comGrouping in YAML
In YAML, each group sits under children, with its own hosts block. Same idea, nested structure.
all:
children:
web:
hosts:
web1.example.com:List a Group's Members
Confirm who belongs where with --list-hosts. It prints exactly the servers a group pattern resolves to.
ansible app -i inventory.ini --list-hostsungrouped Catches Strays
Hosts you list with no group land in the built-in ungrouped group. A quick way to spot servers you forgot to sort.
ansible ungrouped -i inventory.ini --list-hostsGroups Map to Real Tiers
Your web, db, and app groups mirror a classic three-tier stack. Automation now reads like your architecture.
Keep Names Consistent
Pick a naming convention and stick to it. Consistent group names across projects make playbooks reusable and reviews painless.
Quick Check
You list one host under both the [web] and [app] headers. What happens?
Recap
Groups like web, db, and app let you target whole tiers by name. A host can join several groups at once. 🗂️
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Grouping Hosts: web, db & app” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Grouping Hosts: web, db & app”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Grouping Hosts: web, db & app”?
Organize servers into logical groups. You practise DevOps Bootcamp 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 DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp 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 2 of 4.
How long does the “Grouping Hosts: web, db & app” 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 DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp 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
- INI vs YAML Inventory Files
- Grouping Hosts: web, db & app
- Nested Groups & the children Keyword
- Host & Group Variables in the Inventory