Use this when writing YAML for Ansible, Kubernetes or CI.
YAML
YAML is a human-friendly data format based on indentation, used for Ansible playbooks, Kubernetes manifests, CI pipelines and Compose files. Indentation and type guessing are frequent sources of errors.
1. YAML: human-friendly superset of JSON with indentation.
2. Spaces only, consistent indentation.
3. Implicit typing pitfalls (yes/no, 0123, 1.10).
4. Quote ambiguous strings.
5. Lint in CI.
YAML text → safe parser → data
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 Effective-state and workload closure Verify boundary
Local intent: YAML reference under Data Formats in the Automation Domain.
Step 2 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as encoding/BOM issues, delimiter/quoting ambiguity, duplicate keys, namespace drift, scalar coercion, invalid schema assumptions and parser success without consumer-valid semantics, choosing the cases most relevant to YAML node types, tags, anchors/aliases, scalar resolution and consumer schema; parsing alone does not show the values have intended types.
Step 3 Branching troubleshooting Narrow the fault
Path: Automation → Data Formats → YAML. Local intent: YAML reference under Data Formats in the Automation Domain.
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.
Subtopics
Go one level deeper into this subject.
YAML mappings are key-value pairs written key: value, nested by indentation with spaces, never tabs.
Subtopic SequencesYAML sequences are lists, written with a dash per item or inline as [a, b].
Subtopic ScalarsYAML scalars are single values — strings, numbers, booleans, null.
Subtopic AnchorsYAML anchors (&name) and aliases (*name) reuse a block elsewhere in the same file, and merge keys (<<: *name) combine it with extra fields, reducing repetition in CI and Compose files.
Subtopic ValidationValidate YAML with yamllint for syntax and style, then against a schema or the tool's own checks (ansible-lint, kubectl --dry-run, docker compose config) before using it.
- YAML uses indentation with spaces, never tabs.
- Unquoted yes, no, on and 1.10 change type.
- Lint before use.
yamllint file.yaml— lintyq '.' file.yaml— parsepython3 -c 'import yaml;yaml.safe_load(open("f.yaml"))'— safe load
ReferenceWhy it matters1 section · depth on demand
Internals and state
Local intent: YAML reference under Data Formats in the Automation Domain.
ReferenceImportant terms & boundaries2 sections · depth on demand
Mechanics
The linked authority for bounded mechanics is YAML 1.2.2 Specification; documentation support is separate from observed lab/production Evidence.
In depth
YAML is a human-friendly data format based on indentation. It expresses the same structures as JSON — mappings, lists, scalars — with less punctuation, which is why Ansible, Kubernetes, CI pipelines and many configuration files use it.
device: sw-oslo-07
vlans:
- id: 10
name: MGMT
- id: 20
name: USERS
uplink: { interface: Te1/1/1, enabled: true }
YAML is a superset of JSON, so valid JSON is valid YAML. Its convenience comes with traps — indentation errors, implicit typing, tabs not allowed — so lint YAML files in CI (yamllint) and keep files consistently formatted.
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 Data Formats > YAML. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://yaml.org/spec/1.2.2/ · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For YAML node types, tags, anchors/aliases, scalar resolution and consumer schema; parsing alone does not show the values have intended types, prefer typed fields and stable IDs over human presentation text.