Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Validation · YAML

Direct answer

Validate 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.

When to use this

Use this when validating YAML before tools use it.

First 30 seconds

1. Validate YAML syntax (yamllint) and structure (JSON Schema, kubeconform, Ansible argument specs).

2. Run in CI.

3. Fail on unknown keys where possible.

4. Clear messages.

5. Version schemas.

Operational verification

YAML → lint + schema → pass/fail

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
YAML 1.2 data representation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformYAML 1.2 data representation · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when validating YAML before tools use it.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 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 schema and semantic validation before execution, actionable errors with field/path identity and revalidation after defaults/transforms are applied.

Step 2 Common mistakes Narrow the fault
  • No schema validation of YAML data.
Evidence references

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.

observation · 1
Key points
  • yamllint checks syntax and style.
  • Tools add their own validation.
  • Schemas catch structural errors.
Key checks
  • check-jsonschema --schemafile schema.json file.yaml — schema validation
  • yamllint file.yaml — style
  • kubeconform manifest.yaml — Kubernetes schema
ReferenceWhy it matters1 section · depth on demand

In depth

YAML validation has two levels: syntax (is the file valid YAML?) and schema (does it contain the right keys, types and values?). Both should run in CI, because YAML errors otherwise surface as confusing failures when a playbook or pipeline runs.

yamllint -s inventories/ playbooks/
python3 -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))' vars.yml
check-jsonschema --schemafile schemas/site.json sites/*.yml
kubeconform -strict manifests/

A .yamllint configuration in the repository keeps rules consistent (indentation, line length, truthy values, document start). For domain-specific files, tools like ansible-lint, kubeconform and actionlint add schema knowledge.

ReferenceImportant terms & boundaries1 section · depth on demand
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docYAML 1.2 data representation current

Authoritative/upstream documentation reviewed for bounded claims in YAML > Validation. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://yaml.org/spec/1.2.2/ · confidence 94%
Confirmation

Confirm action

Continue?