Automation · Templates
Variables
Cheat sheet · https://pcornel.dk/topic.php?topic=5808
Answer
Template variables are the values inserted into templates, coming from inventory, a source of truth or files. Missing or wrongly typed variables are the most common template bug.
Remember
- Variables come from inventory or a source of truth.
- Types matter.
- Missing variables cause most bugs.
First checks
ansible-inventory --host <host> | jq .— variables available- Variable naming conventions — clarity
- Defaults via | default() — missing values
Verify in this order
variables → template placeholders
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Templates → Variables · operational reference
| Layer | Templates → Variables operational reference |
|---|---|
| Context identity | Jinja 3.1/current + exact revision/input/target identity |
| Persistent intent | Versioned contract/configuration with explicit ownership and prerequisites |
| Verification | Validate inputs/read current state → exercise bounded operation → independent target read-back |
| Output contract | Preserve structured status/IDs/properties before human formatting |
| Failure boundary | Separate source/input/engine/controller execution from downstream target outcome |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5808