Quiz Entry - updated: 2026.10.30
What formatting rules does a YAML playbook file have to follow?
Save as .yml or .yaml; start the document with three dashes and optionally end it with three dots; indent with spaces only, never tabs; give siblings the same indentation and indent children further than their parent.
- Extension:
.ymlor.yaml. - Document markers: the file begins with a line of three hyphens (the YAML document start) and may end with a line of three dots
.... - Spaces, not tabs: YAML forbids tab characters for indentation. A single tab is a syntax error, which is why editors for Ansible are set to insert spaces.
- Same level, same indentation: items of the same list, or keys of the same object, must line up exactly.
- Children further in: anything that belongs to an element must be indented more than that element. How many spaces is up to you (2 is common), as long as you are consistent.
- Blank lines are allowed anywhere for readability.
The reason indentation is so strict: YAML has no braces or brackets in this style. The indentation is the structure. Moving a line two spaces left can turn a module argument into a task keyword, and Ansible then complains about an unknown parameter or does something different.
Go deeper:
YAML Syntax (official docs) — the YAML subset Ansible uses, plus common gotchas.
What is YAML? (Red Hat) — short intro to indentation-based structure.