← All 175 books ansible, one play per page
One play per page

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.


Steve Hodgkiss 7 lessons

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

Contents


Part 1 · The play itself
The first pong4
Part 2 · The inventory
Graph versus list5
Part 3 · Tasks and modules
Idempotence6
Part 4 · Facts and variables
debug, two doors7
Part 5 · The run, controlled
The recap ledger8
Part 6 · Honest failure
Where it broke9
Part 7 · The long view
One honest hour10

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.

Ansible companion · No. 01
the proof

The first pong

a real local run, quoted honestly

the law before the first play: real runs, labelled honestlyno invented ansible outputanywhere in this bookevery fact traced to acached source line$ ansible localhost -m ping -c locallocalhost | SUCCESS => {"changed": false,"ping": "pong"a real local run, quoted verbatimchanged=false: the call asked,and changed nothing on the hosthonest about demos: the runs are real, the plans are labelled

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.

ONE HONEST PLAY

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.

Ansible companion · No. 02
the two views

Graph versus list

the tree draws, the JSON counts

two views of one roster: the tree and the JSONthe graph, for eyesthe list, for scripts@all:|--@webservers:|--localhost|--@dbservers:"hostvars": {"ansible_connection": "local""ansible_port": 1"children": [the tree: for your eyesthe JSON: for programsone roster, honestlypick the dialect your reader needs

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.

ONE HONEST PLAY

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.

Ansible companion · No. 03
the promise

Idempotence

run it twice, change nothing

idempotence: the same page, read twice, changed zeroone of the guiding goals of modules is idempotencythe real runok=3 changed=0the --check rehearsalok=3 changed=0same playbook, second read,same counters, nothing movedchanged=0 on the second read is the promise kept

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.

ONE HONEST PLAY

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.

Ansible companion · No. 04
the messenger

debug, two doors

msg says, var shows

debug: one module, two doorsdebugdoor one: msg"msg": "one play, one page"door two: var"playbook_word": "play"msg carries your sentence;var carries the machine's memorya play that prints its own state debugs itself

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.

ONE HONEST PLAY

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.

Ansible companion · No. 05
the verdict

The recap ledger

seven counts after the run

the recap ledger: seven numbers after every runokchangedunreachablefailedskippedrescuedignoredok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0the failing run read failed=1the healthy run read ok=3read the ledger first,then decide whether to read onthe run compressed to numbers you can compare

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.

ONE HONEST PLAY

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.

Ansible companion · No. 06
the map back

Where it broke

file, line, column, caret

the origin lines: file, line, column, caretOrigin: /root/.hermes/cache/scratch/ansible175demo/fail.yml:7:75 gather_facts: false6 tasks:7 - name: Touch a path that cannot exist ^ column 7a failure is an address: which file, which line, which column

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.

ONE HONEST PLAY

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.

Ansible companion · No. 07
the handoff

One honest hour

a practice plan, labelled as such

one honest hour: six moves, planned and labelled1the version linename what ran2one ad-hoc pongchanged=false3one one-play runread three tasks4list the taskswithout running5graph oneinventory file6read the recapscount the zerosthis book's plan: six moves, one hour, every line traceablewrite down which countersmoved, and which stayed zeroone hour of honest runs beats a year of guessing

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.

ONE HONEST PLAY

Book the hour this week; which of the six moves will surprise you most?

Index

Index


debug, two doors7
Graph versus list5
Idempotence6
One honest hour10
The first pong4
The recap ledger8
Where it broke9