YAML & Config File Fundamentals
Part of the DevOps Roadmap
In short
GitHub Actions, Kubernetes, Ansible, Docker Compose: all YAML. One wrong space and the pipeline fails with a confusing error. Learn the rules once and save yourself many late nights.
YAML is the near-universal configuration format across DevOps tools — CI/CD pipelines, Kubernetes manifests, Ansible playbooks — understanding its indentation-sensitive syntax prevents a huge share of frustrating errors.

Think of it like this
Mummy's grocery list
Mummy writes 'Vegetables' and indents onions and tomatoes under it, then 'Dairy' with milk and paneer under that. The indent alone tells you what belongs where. YAML works exactly like that, so shifting one line by a space moves paneer into the vegetable bag.
Watch it happen
How YAML indentation nests data
1/4Top-level keys sit at column zero. service is a simple key: value pair.
The big ideas
What you need to know
Spaces only, never tabs
YAML forbids tabs for indentation. Set your editor to insert two spaces when you press Tab.
Quote risky values
1.10 becomes the number 1.1, and in older YAML parsers NO can become false. Quote versions and codes.
Maps and lists
key: value makes a map. - item makes a list. Kubernetes files are mostly maps holding lists of maps.
Lint before you push
yamllint or your editor's YAML extension catches bad indentation before CI or kubectl does.
See it in code
Walk through the code
1service: payments2replicas: 33debug: false4version: "1.10" # quoted, or YAML reads it as the number 1.15ports:6 - 80807 - 90908database:9 host: db.internal10 port: 543211env:12 - name: LOG_LEVEL13 value: info14notes: |15 Multi-line text keeps16 its line breaks.1/4Simple values: a string, a number, a boolean and a version quoted so it stays a string.
Run yamllint file.yaml or python3 -c "import yaml,sys; print(yaml.safe_load(open(sys.argv[1])))" file.yaml to see how a parser reads it.
Save yourself the pain
Common mistakes
Oops
Mixing tabs and spaces, or 2 and 4 spaces, in the same file.
Do this instead
Use two spaces everywhere, turn on 'show whitespace' in your editor, and lint before committing.
Oops
Writing version: 1.10 or country: NO without quotes.
Do this instead
Quote anything that must stay text: versions, zip codes, country codes and strings like yes or on.
Your mission
Find the YAML bugs
Quick check
Your config has version: 1.10 without quotes. What does a YAML parser give your app?
Go deeper
- 1Write a small YAML file and validate it with an online or CLI YAML linter.
- 2Learn common YAML pitfalls: inconsistent indentation, tabs vs spaces, and quoting rules.
- 3Compare the same configuration expressed in YAML versus JSON to see the readability trade-off.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.