YAML and Variable Errors¶
Section status: outline
This page is scoped but not yet written in full prose. The sections below define what it will cover.
Why This Exists¶
These two error categories both surface before a task ever reaches a host — they're the fastest to fix, once you know where to look, and the most common first-week source of "the playbook does nothing" confusion.
What It Will Cover¶
- Reading a YAML parser's line/column error precisely — it often points slightly after the real mistake (a missing colon or bad indentation one line earlier is a common false trail)
ansible-playbook --syntax-checkas the fastest zero-risk first check on any edited playbook'dict object' has no attribute 'X'— usually a typo in a variable/dictionary key, or a variable that's a different shape than assumed; pair withansible.builtin.debug: var=on the parent object to inspect its real shape'X' is undefined— tracing which of the variable sources was expected to provide it, usingansible-inventory --host <name>per Variable Precedence- The YAML "Norway problem" (
no/yes/country codes parsing as booleans) surfacing as a confusing type error deep in a task, not at parse time
Interview Questions¶
- A task fails with
'X' is undefined— what's your process for finding where it should have come from? - Why does a YAML syntax error sometimes point to the wrong line?
Next¶
Continue to Module and Execution Errors.