0Pricing
DevOps Bootcamp · Lesson

Nested Groups & the children Keyword

Build group-of-groups hierarchies.

Nested Groups & the children Keyword is a free DevOps Bootcamp lesson on CoddyKit — lesson 3 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 DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Groups Inside Groups

Sometimes you want a group made of other groups. Ansible calls this a group of groups, built with the children keyword.

The children Keyword in INI

In INI, a header like [prod:children] declares a parent whose members are other group names, not hosts.

[prod:children]
web
db

Define the Child Groups First

The child groups must exist with their own hosts. The parent then simply references them by name.

[web]
web1.example.com

[db]
db1.example.com

Hosts Roll Up to the Parent

Target prod and Ansible reaches every host inside web and db. One name now covers a whole environment.

ansible prod -i inventory.ini --list-hosts

Nesting in YAML

YAML nests naturally: a group lists more groups under its own children key, which can nest as deep as you like.

all:
  children:
    prod:
      children:
        web:
        db:

Build Real Hierarchies

Combine layers like region and role: datacenter contains prod, which contains web and db. Inventory mirrors your org.

[datacenter:children]
prod
staging

A Host Inherits Every Parent

If web is a child of prod, a web host belongs to web and prod and all. Membership flows upward automatically.

Variables Flow Down

Set a variable on the parent group and every child host inherits it, unless a more specific group overrides it.

[prod:vars]
env=production

Avoid Circular Children

A group cannot be a child of itself, directly or through a loop. Ansible rejects circular hierarchies when it parses.

Verify the Tree

Use the inventory graph to see your nesting clearly. The --graph flag draws parents and their children as a tree.

ansible-inventory -i inventory.ini --graph

Hierarchy Tames Scale

Nested groups let you say prod or web-prod precisely. As fleets grow, children keep targeting both broad and surgical.

Quick Check

You want a parent group whose members are the web and db groups. Which INI header do you use?

Recap

The children keyword nests groups into hierarchies. Hosts inherit every parent, and group variables flow down the tree. 🌳

Frequently asked questions

Is the “Nested Groups & the children Keyword” lesson free?

Yes — the full text of “Nested Groups & the children Keyword” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Nested Groups & the children Keyword”?

Build group-of-groups hierarchies. 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; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Nested Groups & the children Keyword” 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

  1. INI vs YAML Inventory Files
  2. Grouping Hosts: web, db & app
  3. Nested Groups & the children Keyword
  4. Host & Group Variables in the Inventory
← Back to DevOps Bootcamp