ansible, one play per page
Twenty-eight lessons on what Ansible is: a suite of software tools that enables infrastructure as code, open-source, originally written by Michael DeHaan in 2012 and acquired by Red Hat in 2015; the law of one play per page; the playbook as a YAML file that stores lists of tasks; the inventory of hosts and groups, the graph and the list; task anatomy, modules and idempotence; facts gathered, set and shown; the controlled run: check mode, the task listing, two plays in one file and the recap ledger of ok, changed, unreachable, failed, skipped, rescued and ignored; the honest failure, its origin line and exit code two; hosts mapped to roles; the long view from Le Guin's 1966 word to one honest hour of practice.
One play, one page, one honest recap. That is the shape of this book.
ansible, one play per page
Twenty-eight lessons on what Ansible is: a suite of software tools that enables infrastructure as code, open-source, originally written by Michael DeHaan in 2012 and acquired by Red Hat in 2015; the law of one play per page; the playbook as a YAML file that stores lists of tasks; the inventory of hosts and groups, the graph and the list; task anatomy, modules and idempotence; facts gathered, set and shown; the controlled run: check mode, the task listing, two plays in one file and the recap ledger of ok, changed, unreachable, failed, skipped, rescued and ignored; the honest failure, its origin line and exit code two; hosts mapped to roles; the long view from Le Guin's 1966 word to one honest hour of practice.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
An honest book about its demos: ansible-core 2.22.0 ran in a scratch virtualenv on the machine that built this book, and every quoted output line in these pages was captured from those real runs (the version output, an ad-hoc ping module call, a one-play playbook with debug and set_fact, a two-play playbook, one honest failing play whose error text is never quoted, a check-mode run, a task listing, a facts run, and an inventory graph and list), quoted verbatim from the captured run log. No ansible output was invented. Every other fact is as the primary source states it, fetched and read during this build: the Wikipedia articles Ansible (software), Infrastructure as code, Configuration management, YAML and Red Hat, cached verbatim beside this book. No facts come from Reddit, Stack Overflow, vendor blogs or commercial sites. Every lesson that describes a practice exercise carries the label 'this book's plan', never posing as a captured fact. Independent, not affiliated with Red Hat or the Wikimedia Foundation.
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
Per this book's plan and a real local run captured at dispatch, the ad-hoc command ansible localhost -m ping -c local answered localhost SUCCESS with changed false and ping pong, and the run log records the warning that no inventory was parsed, only implicit localhost is available.
The first pong
Before anything else, the law: ansible-core 2.22.0 ran in a scratch virtualenv on this machine, every quoted output line was captured from those real runs, and no ansible output was invented.
A real local run, the first answer the box earned: localhost | SUCCESS => { with "changed": false, and "ping": "pong". The run also warned: No inventory was parsed, only implicit localhost is available.
changed=false is the first honest number of the book: the call asked a question and changed nothing.
What does changed=false tell you about what the call did to the machine?
Per real local runs captured at dispatch, ansible-inventory --graph printed the group tree while ansible-inventory --list answered in JSON, whose hostvars held ansible_connection local and ansible_port 1 for localhost, and whose all children were ungrouped, webservers and dbservers.
Graph versus list
Two real local runs, two shapes of one roster. The graph draws the tree; the list answers in JSON, with "ansible_connection": "local" and "ansible_port": 1 under hostvars.
The list also names the children of all: "ungrouped", then "webservers", then "dbservers".
The tree is for your eyes, the JSON is for programs: same inventory file, same host, two honest dialects.
When would a machine read the list instead of the graph, and what does it gain?
Per the Wikipedia Ansible (software) article, one of the guiding goals of modules is idempotency, which means that even if an operation is repeated multiple times, for example upon recovery from an outage, it will always place the system into the same state, and it is possible to write playbooks that are not idempotent; per real local runs captured at dispatch, the one-play playbook and its check-mode run both ended ok=3 changed=0.
Idempotence
Per the article, one of the guiding goals of modules is idempotency: even if an operation is repeated multiple times, it will always place the system into the same state.
A real local pair: the one-play playbook and its --check rehearsal both ended ok=3 and changed=0. The second read of the same page changed nothing.
The article states the edge honestly too: it is possible to write playbooks that are not idempotent. The goal is a discipline, not a guarantee.
How do the recap counters prove idempotence without your watching the screen?
Per real local runs captured at dispatch, the debug module answered through two doors: the msg argument printed one play, one page, and the var argument printed playbook_word play, and both tasks closed with ok for localhost.
debug, two doors
The messenger module has two doors. Through msg you hand it the words: a real local run printed "msg": "one play, one page".
Through var you hand it a name and it fetches the value: "playbook_word": "play". Both tasks closed with ok: [localhost] =>.
One door speaks your sentence, the other speaks the machine's memory. A play that can print its own state debugs itself.
Which door proves a variable holds what you think, and why that one?
Per real local runs captured at dispatch, every playbook ended with the line PLAY RECAP followed by a host line counting ok, changed, unreachable, failed, skipped, rescued and ignored; the one-play run read ok=3 changed=0 failed=0 and the failing run read ok=0 failed=1.
The recap ledger
Every captured run ends the same honest way: PLAY RECAP, then one host line with seven counts: ok, changed, unreachable, failed, skipped, rescued, ignored.
The healthy run read ok=3 and changed=0; the failing run read ok=0 and failed=1. Different story.
Read the ledger first: the run compressed to seven numbers you can compare across every run you make.
Which two counters would you check first after an overnight run, and why?
Per a real local run captured at dispatch, after the failing task the run printed an Origin line naming the playbook file fail.yml at line 7 column 7, then showed the numbered context lines 5 gather_facts false, 6 tasks, and 7 the failing task's name, with a caret marking column 7.
Where it broke
The run walks you back to the line you wrote. A real local run printed Origin: naming fail.yml:7:7, then showed the neighborhood: line 5 gather_facts: false, line 6 tasks:, line 7 the failing task's name, with a caret at column 7.
File, line, column: a failure is an address, not a mood. Every breaking run you ever meet ends at this same door.
What does the caret's column tell you that the line number alone does not?
Per this book's plan, one honest hour of practice is: run the version query and name what ran, earn one ad-hoc pong, run the one-play playbook and read its three task lines, list a playbook's tasks without running them, graph one inventory file, and read the recap ledger of every run, noting which counters moved.
One honest hour
Per this book's plan, one honest hour: read the version output and name what ran; earn one pong; run the one-play playbook and read its three task lines.
Then list a playbook's tasks without running them, graph one inventory file, and close the hour reading PLAY RECAP lines, noting which counters moved and which stayed zero.
Six moves, one hour, every line traceable to a run you watched yourself.
Book the hour this week; which of the six moves will surprise you most?