Concept and mechanism
A useful playbook describes conditions required for the outcome, including dependencies an administrator might have created manually. Running it on an old host can hide that preparation. Under EX294 objectives, playbooks are applied to fresh systems and configurations must persist after reboot.
Therefore, distinguish error-free execution, intended state, and reconstruction of that state at boot. A currently active mount does not prove persistent configuration exists. A directory readable by a group also needs search permission to allow traversal.
Its mode should represent access requirements without adding write merely to remove an error.
Guided application
In a fictional batch project, reproduce configuration on a disposable host and compare the initial execution with a repeat. A state module can avoid unnecessary changes; a command does not become idempotent simply by using register. Creates can prevent repetition when a reliable marker exists and is created only after validated success.
That marker does not replace validation of the migration it represents. In a registered result, rc, stdout, and changed mean different things. Document acceptable codes before building conditions.
Facts are observations too: ansible_date_time gathered at startup does not advance like a live clock. To measure a later phase, collect time evidence appropriate to that moment.
Measure state, reporting and consumption
The lab starts with a fresh directory and user-owned synthetic files. A copy task publishes port=8080 with mode 0640. The first execution changes the destination and the second reports changed=0.
Compare three things: published bytes, metadata and how a consumer uses the result. Unchanged repetition helps detect unnecessary work, but is acceptable only when retained state meets the request. Another destination already contains 8080 when the task starts requesting 9090 with force:false.
The exercise finishes unchanged and retains the old port. Absence of differences does not correct a contract that preserves outdated contents. For a real batch, acceptance should specify expected configuration and how it will be observed, alongside the automation exit code.
Repair drift invisible to a content hash
After the first repeat, the runner changes only stable.conf mode to 0666. Its content SHA-256 stays the same. Check mode predicts a change, but subsequent inspection still shows 0666.
Only actual execution restores 0640; another repeat returns to changed=0. This cycle demonstrates detection, prediction, repair and stability without confusing the four stages. If a pipeline compares only byte hashes, permission drift goes unnoticed.
The same care applies to owner, group and other environment-required attributes. Declared permissions also do not establish access for an identity absent from the exercise. This lab observes local mode without validating ACLs, SELinux or remote-service groups. That service’s acceptance needs its actual identity and context.
Do not hide effects behind change counts
An original script appends line effect to a file whenever called. The play runs it twice with changed_when:false. Both recaps show zero changes, but the file ends with two lines.
This observation separates the execution decision from reporting policy. If a requirement prohibits repeating an operation, define intended state or an execution condition supported by appropriate evidence. Do not substitute suppressed reporting.
Another experiment applies state:touch to an old marker and observes a new mtime. With access_time and modification_time explicitly set to preserve, the existing marker retains mtime and the task reports no change. Choose that policy only when marker meaning permits retained times; if it represents a recent execution, preserving an old timestamp would be misleading.
Repeat the exercise and hand over verifiable criteria
Predict which tasks should change files and which properties may remain wrong despite changed=0. Run the runner in a fresh directory and inspect retained observations. Both final runs passed 34 checks across 23 invocations each on core 2.19.0 and a local macOS filesystem.
Then change a copy of the inputs and repeat detection, repair and inspection. The exercise also creates mode-0664 destinations and changes their bytes without an explicit mode. Even with umask 0077, previous mode remains.
Declaring 0640 corrects it under both exercised umasks. Hand RUN the expected policy and corresponding observations, including evidence limits. Connect this lesson with data contracts, inventories, account permissions and template validation.
Remote services and reboot persistence still require their own rehearsals.
The mount works before reboot; rehearsal ends only after confirming the mounted resource afterward.
Common pitfalls
Prepared host as universal proof; changed as success; marker created before validation.
Related topics: Inventories, variables, and configuration · Access and execution environment · Git, dev containers, and rehearsals
Check effects and required state; changed=0 is useful only with correct acceptance criteria.
References
- EX294 Advanced System Administrator in Ansible objectives · EX294 objectives inspected 2026-09-30
- Copy contents and metadata · Current primary reference; original local module experiment pinned to core 2.19.0
- Manage filesystem objects · Current primary reference; original local module experiment pinned to core 2.19.0
- Inspect filesystem status · Current primary reference; original local module experiment pinned to core 2.19.0
- Check-mode predictions · Current primary reference; original local module experiment pinned to core 2.19.0
- Change reporting and error handling · Current primary reference; original local module experiment pinned to core 2.19.0
- Linux rename manual: descriptors and links · Current Linux primary manual; separate local macOS experiment, not RHEL runtime verification