Use it when the symptom is “Variable Problems”: work through the layers in order and stop at the first one that fails.
Variable Problems
Variable Problems isolates wrong, missing, shadowed or unexpectedly coerced values by tracing variable definition, precedence, scope, defaults and runtime expansion to the effective value used by an operation.
1. Variable problems: wrong precedence, typos, wrong type, missing values.
2. Inspect effective values.
3. Trace source.
4. Simplify precedence.
5. Validate with specs.
sources → precedence → effective value
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
variable sources → precedence/scope → type/coercion/default → per-target effective value → template/task expansion → operation → target state
Healthy evidence: effective value and provenance are explainable per target, types/defaults are intentional, the corrected source survives plan/render, and target result verifies.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: only one variable file is inspected, empty/undefined values are conflated, secret masking hides whether a variable exists, or generated values are manually overridden.
Step 3 Common mistakes Narrow the fault
- Variable precedence surprises.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Variable defined ≠ intended definition won precedence.
- Empty string ≠ undefined ≠ null ≠ false.
- Displayed variable ≠ same value used later after mutation/override.
- Correct global value ≠ per-target override is correct.
ansible-inventory --host <h> | jq .— effective varsansible <h> -m debug -a 'var=<v>'— value- Precedence/override location — source
ReferenceWhat it is1 section · depth on demand
Core model
Capture variable name and safe effective value; enumerate all definition sources in precedence order; distinguish undefined from empty/null/false; inspect type/coercion and per-target overrides; fix authoritative source or precedence; rerun render/plan and verify target outcome.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Variable inspection shows a value at one evaluation boundary; later overrides, lazy evaluation or target-specific scope can still change behavior.
In depth
Variable problems in automation are wrong, missing or unexpectedly overridden values. In Ansible they usually come from precedence; in scripts from scope, environment or type conversion.
ansible -i inventory/ sw01 -m ansible.builtin.debug -a 'var=hostvars[inventory_hostname].ntp_servers'
| Symptom | Likely cause |
|---|---|
| Value differs per host unexpectedly | Defined in several groups |
| Extra var ignored? | Never — check spelling |
'false' treated as true | String instead of boolean |
| Empty value in script | Variable not exported to child process |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation Troubleshooting > Variable Problems. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/architecture/patterns/retry · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Variable Problems troubleshooting proof-boundary map
Fast symptom/scope, first-failed-boundary, effective-outcome and recovery/closure map for Variable Problems.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Symptom / scope | Time window, immutable source/run identity, effective inputs and exact targets are explicit | Floating source, changed inputs or ambiguous targets destroy reproducibility |
| First failed boundary | Transport/auth/dependency/render/operation evidence identifies the earliest divergence | Investigation starts at the final error and skips earlier unproven boundaries |
| Effective outcome | Controller result is paired with target read-back and workload/service acceptance | Green execution state or changed symptom substitutes for effective-state verification |
| Recovery / closure | Minimal change restores the original test and regression/partial-state checks are clean | Broad retry or unrelated edits make the incident non-reproducible and hide residual state |