Batch 2: JavaScript HTML & CSS JSON XML YAML ← Full TOC
Ch.33 XML Ch.34 YAML Ch.35 SQL Databases ← Full TOC

📋 Chapter 34 — YAML

Complete Reference with Copy-Paste Examples
Part of The Direct Path to Linux Ubuntu — free for all students and developers.

4Topics
5Examples
python3Run
YAML 1.2Version
FreeNo login
📄 Open YAML Reference 🏠 YAML Index
📜 Topics Covered
📝 YAML Syntaxscalars, sequences, mappings, anchors, multiline…
🐍 YAML in Pythonsafe_load, dump, load_all, custom types…
⚙️ YAML in DevOpsKubernetes, Docker Compose, Ansible, GH Actions…
⚖️ YAML vs JSON vs TOMLwhen to use which format…
🎓 Why Learn YAML?
⚙️

DevOps Standard

Kubernetes, Helm, Docker Compose, Ansible, GitHub Actions, GitLab CI — every major DevOps tool uses YAML for configuration.

💬

Human-Readable

YAML supports comments, multiline strings, and anchors for reuse — making complex configurations readable and maintainable.

🔗

Superset of JSON

All valid JSON is valid YAML — you can migrate gradually and use JSON-style flow syntax where needed.

☸️

Kubernetes Native

Every Kubernetes resource — Deployments, Services, ConfigMaps, Ingress — is defined in YAML. It's the language of cloud-native.

⚡ Quick Run Reference

Run a YAML program:

# Parse YAML (Python):
pip install pyyaml            # install PyYAML
python3 yaml_demo.py          # run script

# Command-line YAML processing with yq:
snap install yq               # Ubuntu/Debian
brew install yq               # macOS
yq '.' config.yaml            # pretty-print
yq '.database.host' config.yaml  # extract field
yq -o json '.' config.yaml    # convert to JSON
yq -P '.' config.json         # convert JSON to YAML

# Validate YAML:
python3 -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]))" file.yaml
yamllint file.yaml            # install: pip install yamllint
Previous Home Next