Chapter Two
Inventory
The list of machines Ansible can manage and the groups they belong to — from a hand-written INI file to cloud dynamic inventory that always sees the servers that actually exist.
A playbook says what to do; inventory says to whom. It is the list of hosts Ansible can reach, the groups they fall into, and the variables that ride along with each. Get the inventory right and a single playbook runs cleanly against staging or production by swapping one flag; get it wrong and a change meant for one host reaches the whole fleet.
This chapter builds the Larkspur inventory from the ground up. The model of hosts and groups, the two static file formats, where variables live, how patterns target a subset, and finally dynamic inventory that queries the cloud so the host list is generated rather than maintained. Six pages that turn "which hosts?" from a guess into a thing you can verify before every run.
Topics in This Chapter
all and ungrouped groups, group-of-groups, and how inventory separates environments without any state.group_vars/ and host_vars/ directories, why they beat inline inventory vars, and how all → group → host layering powers per-environment overrides.--limit as a safety rail and --list-hosts as the check that keeps a quick fix from hitting the fleet.keyed_groups from cloud tags, and the Terraform handoff.constructed plugin for derived groups, caching, and merge precedence.