Pcornel
Automation · Templates

Variables

Cheat sheet · https://pcornel.dk/topic.php?topic=5808

Back to the Topic

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

LayerTemplates → Variables operational reference
Context identityJinja 3.1/current + exact revision/input/target identity
Persistent intentVersioned contract/configuration with explicit ownership and prerequisites
VerificationValidate inputs/read current state → exercise bounded operation → independent target read-back
Output contractPreserve structured status/IDs/properties before human formatting
Failure boundarySeparate 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

Confirmation

Confirm action

Continue?