DEV Community

Cover image for YAML Learning Lab
Rahimah Sulayman
Rahimah Sulayman

Posted on

YAML Learning Lab

Introduction

YAML is one of the most widely used configuration and data serialization formats across modern cloud engineering, DevOps, automation, and CI/CD environments.

From GitHub Actions workflows to Kubernetes manifests and infrastructure configuration, YAML provides a human-readable way to represent structured data while remaining easy for machines to process.

The YAML Learning Lab is a practical technical repository focused on YAML syntax, structured data representation, configuration patterns, validation, and its application within modern DevOps workflows.

đź”— GitHub Repository: YAML Learning Lab


A Brief History of YAML

YAML was created in 2001 by Clark Evans, Ingy döt Net, and Oren Ben-Kiki as a human-friendly data serialization language.

The name YAML originally stood for "Yet Another Markup Language." It was later reinterpreted as "YAML Ain't Markup Language", emphasizing that YAML is a data serialization language, rather than a markup language.

This distinction is important.

Markup languages such as HTML are primarily concerned with describing the structure and presentation of documents, while YAML focuses on representing structured information and configuration in a format that is readable by both humans and machines.

Today, YAML is widely used in:

  • Cloud configuration
  • CI/CD pipelines
  • Kubernetes
  • Infrastructure as Code
  • Application configuration
  • Automation
  • DevOps tooling

Project Overview

The repository brings together practical YAML examples covering:

  • Key-value pairs
  • Mappings
  • Nested structures
  • Sequences
  • Lists of objects
  • Data types
  • Comments
  • Quoted strings
  • Multiline strings
  • Anchors and aliases
  • Merge keys
  • Multi-document YAML
  • GitHub Actions workflows
  • YAML validation with Python and PyYAML

The project demonstrates how YAML syntax translates into structured configuration used by modern engineering tools.


Project Setup

The project was organized as a Git repository with individual YAML files representing different concepts.

Project setup

The repository structure keeps each concept isolated while also providing a final configuration challenge that combines multiple YAML features.


YAML Fundamentals

The first examples introduce YAML's basic key-value structure.

name: Raphael
role: Cloud Engineer
country: Nigeria
Enter fullscreen mode Exit fullscreen mode

A YAML mapping associates each key with a value:

Key Value
name Raphael
role Cloud Engineer
country Nigeria

This simple structure is the foundation for more complex YAML configurations.

YAML basics


Mappings and Nested Structures

YAML uses indentation to represent relationships between data elements.

For example:

person:
  name: Raphael
  role: Cloud Engineer
Enter fullscreen mode Exit fullscreen mode

Here, name and role are properties nested under person.

Nested structures allow configuration to represent relationships between related pieces of information without requiring complex syntax.

Mappings

Nested mappings extend this idea by allowing multiple levels of configuration:

person:
  name: Raphael
  age: 30
  country: Nigeria
Enter fullscreen mode Exit fullscreen mode

Nested mappings

One important YAML rule becomes obvious here:

Indentation defines structure.

YAML configuration should use spaces for indentation rather than tabs.


Sequences

YAML sequences represent ordered collections.

They are identified using a hyphen (-):

skills:
  - Azure
  - Docker
  - Kubernetes
  - Git
Enter fullscreen mode Exit fullscreen mode

This creates a list of four values under the skills key.

Sequences are common in configuration files for representing:

  • Packages
  • Ports
  • Hosts
  • Skills
  • Resources
  • Configuration options

Sequences


Lists of Objects

YAML sequences can contain mappings, making it possible to represent collections of structured objects.

employees:
  - name: Raphael
    role: Cloud Engineer

  - name: Sarah
    role: DevOps Engineer

  - name: David
    role: Solution Architect
Enter fullscreen mode Exit fullscreen mode

Each list item contains multiple properties.

This pattern is particularly useful when configuration describes multiple resources that share a common structure.

Lists of objects


YAML Data Types

YAML supports several common data types.

person:
  name: Raphael
  age: 30
  salary: 4500.50
  active: true
  verified: false
  phone: null
Enter fullscreen mode Exit fullscreen mode

These values represent different data types:

Value Type
Raphael String
30 Integer
4500.50 Floating-point number
true Boolean
false Boolean
null Null

Understanding how YAML interprets values is important when configuration is consumed by automation tools or programming languages.

YAML data types


Comments and Quoted Strings

Comments begin with # and are ignored by YAML parsers.

# Employee Information Configuration
city: Lagos
Enter fullscreen mode Exit fullscreen mode

Comments are useful for documenting configuration and explaining why a particular value or section exists.

YAML also supports quoted strings:

message: "Welcome: Cloud Engineers!"
Enter fullscreen mode Exit fullscreen mode

Quoting can make the intended value explicit, particularly when a value contains characters that could otherwise be interpreted specially.

Comments and strings


Multiline Strings

YAML provides block scalar syntax for storing multiline text.

There are two important styles:

  • | — literal block
  • > — folded block

Literal Block

The | character preserves line breaks.

bio_literal: |
  I enjoy learning Azure.
  I build cloud solutions.
  I teach DevOps.
Enter fullscreen mode Exit fullscreen mode

Folded Block

The > character folds consecutive lines into a paragraph-like value.

bio_folded: >
  I enjoy learning Azure.
  I build cloud solutions.
  I teach DevOps.
Enter fullscreen mode Exit fullscreen mode

The difference matters when YAML is being used to store scripts, documentation, certificates, configuration blocks, or other multiline content.

Multiline strings


Anchors, Aliases, and Merge Keys

YAML provides anchors and aliases for reusing configuration without repeatedly defining the same values.

An anchor is created using &:

defaults: &default
  country: Nigeria
  role: Student
Enter fullscreen mode Exit fullscreen mode

The configuration can then be reused using an alias:

student1:
  <<: *default
  name: Raphael
Enter fullscreen mode Exit fullscreen mode

The << merge key incorporates the values from the anchored mapping.

Another object can reuse the same configuration:

student2:
  <<: *default
  name: Sarah
Enter fullscreen mode Exit fullscreen mode

This approach reduces duplication and makes shared configuration easier to maintain.

Anchors and aliases


Multi-Document YAML

A YAML file can contain multiple independent documents.

The document separator is:

---
Enter fullscreen mode Exit fullscreen mode

For example:

student1:
  name: Raphael

---
name: Third Document Stream
Enter fullscreen mode Exit fullscreen mode

The separator marks the beginning of another YAML document.

This becomes important during validation because a file containing multiple documents must be parsed accordingly.

The repository demonstrates this concept in anchors.yaml.


YAML in GitHub Actions

YAML is heavily used in CI/CD systems.

The repository includes a GitHub Actions workflow:

name: Build Project

on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Building project..."
Enter fullscreen mode Exit fullscreen mode

The workflow demonstrates several important GitHub Actions concepts.

Workflow Name

name: Build Project
Enter fullscreen mode Exit fullscreen mode

Defines the workflow's name.

Trigger

on:
  push:
Enter fullscreen mode Exit fullscreen mode

Specifies that the workflow runs when changes are pushed to the repository.

Job

jobs:
  build:
Enter fullscreen mode Exit fullscreen mode

Defines a job named build.

Runner

runs-on: ubuntu-latest
Enter fullscreen mode Exit fullscreen mode

Specifies the GitHub-hosted runner that executes the job.

Steps

steps:
  - uses: actions/checkout@v4
  - run: echo "Building project..."
Enter fullscreen mode Exit fullscreen mode

The first step checks out the repository contents.

The second executes a shell command.

GitHub Actions workflow


Final Configuration Challenge

The student-profile.yaml configuration combines several YAML concepts into one structured document.

It includes:

  • Mappings
  • Nested mappings
  • Sequences
  • Strings
  • Integers
  • Floating-point numbers
  • Booleans
  • Multiline strings
  • Folded strings
  • Anchors
  • Aliases
  • Merge keys

The shared configuration begins with an anchor:

default_profile: &default
  role: Student
  country: Nigeria
  active: true
  score: 95.5
Enter fullscreen mode Exit fullscreen mode

The configuration is then reused:

user1:
  <<: *default
  name: Sarah

user2:
  <<: *default
  name: David
Enter fullscreen mode Exit fullscreen mode

The file also contains sequences:

skills:
  - Azure
  - Docker
  - Kubernetes

hobbies:
  - Coding
  - Reading
Enter fullscreen mode Exit fullscreen mode

Nested mappings:

address:
  street: 12 Cloud Way
  city: Abuja
  country: Nigeria
Enter fullscreen mode Exit fullscreen mode

And both multiline string styles:

bio_literal: |
  I enjoy learning Azure.
  I build cloud solutions.
  I teach DevOps.

bio_folded: >
  I enjoy learning Azure.
  I build cloud solutions.
  I teach DevOps.
Enter fullscreen mode Exit fullscreen mode

Student profile configuration

This configuration demonstrates how multiple YAML structures can be combined to represent realistic configuration data.


YAML Validation

Configuration should be validated before being used by automation systems.

This repository uses Python, PyYAML, and Linux command-line tools to validate the YAML files.

Validate All YAML Documents

python3 -c 'import yaml, glob; [list(yaml.safe_load_all(open(f))) for f in glob.glob("*.yaml")]; print("All YAML files valid!")'
Enter fullscreen mode Exit fullscreen mode

This command:

  1. Starts Python 3 using python3.
  2. Uses -c to execute Python code directly from the command line.
  3. Imports the PyYAML library with import yaml.
  4. Imports Python's glob module with import glob.
  5. Uses glob.glob("*.yaml") to find every .yaml file in the current directory.
  6. Uses open(f) to open each YAML file.
  7. Uses yaml.safe_load_all() to parse all YAML documents within each file.
  8. Uses list() to force all documents to be parsed.
  9. Uses a list comprehension to apply the validation to every YAML file.
  10. Uses print() to display a success message after all files are parsed successfully.

The use of safe_load_all() is important because anchors.yaml contains multiple YAML documents separated by ---.

Check for Illegal Tab Characters

YAML indentation should use spaces rather than tabs.

The repository also checks for tab characters:

grep -n $'\t' *.yaml || echo 'No illegal tab characters found!'
Enter fullscreen mode Exit fullscreen mode

Breaking down the command:

Part Meaning
grep Searches files for a specified pattern.
-n Displays the line number where a match is found.
$'\t' Represents a tab character in Bash.
*.yaml Targets all .yaml files in the current directory.
`
{% raw %}echo Prints text to the terminal.

If no tabs are detected, the command prints:

No illegal tab characters found!
Enter fullscreen mode Exit fullscreen mode

YAML validation

These checks provide basic validation for both YAML syntax and indentation consistency.


Git and Repository Management

The project was maintained using Git and published to GitHub.

Git was used to track changes, create commits, maintain the main branch, and synchronize the repository with GitHub.

The final repository includes:

yaml-learning-lab/
├── docs/
│   └── lessons.md
├── screenshots/
├── README.md
├── anchors.yaml
├── lesson1.yaml
├── lesson2.yaml
├── lesson3.yaml
├── lesson4.yaml
├── lesson5.yaml
├── lesson6.yaml
├── lesson7.yaml
├── multiline.yaml
├── student-profile.yaml
└── workflow.yaml
Enter fullscreen mode Exit fullscreen mode

Git history and status

The complete implementation, documentation, YAML files, and supporting evidence are available in the repository:

View the SKILL.SCH YAML Learning Lab on GitHub


Why YAML Matters in Cloud and DevOps

YAML is more than a configuration format. It is an important component of modern engineering workflows.

The concepts demonstrated in this repository appear in technologies such as:

  • GitHub Actions
  • Kubernetes
  • Docker Compose
  • Ansible
  • Azure DevOps
  • Infrastructure as Code tools
  • Application configuration systems
  • Cloud automation platforms

The same fundamental ideas—mappings, sequences, nesting, data types, multiline values, and reusable configuration—appear repeatedly across these technologies.

Understanding YAML therefore makes it easier to read, write, troubleshoot, and maintain configuration-driven systems.


Key Takeaways

The YAML Learning Lab demonstrates how YAML progresses from simple key-value pairs to structured configuration used in real-world DevOps environments.

The repository covers:

  • YAML syntax and structure
  • Mappings and nested mappings
  • Sequences and lists of objects
  • Data types
  • Comments and quoted strings
  • Literal and folded multiline strings
  • Anchors, aliases, and merge keys
  • Multi-document YAML streams
  • GitHub Actions workflow configuration
  • YAML validation using Python and PyYAML
  • Git-based project management

The project also demonstrates an important engineering principle:

Configuration should be readable, structured, reusable, and validated before it becomes part of an automation workflow.


Summary

The YAML Learning Lab provides a practical technical reference for YAML and its role in cloud engineering and DevOps.

From basic mappings and sequences to anchors, multiline strings, GitHub Actions, and automated validation, the repository brings together core YAML patterns required for working with configuration-driven tooling.

More importantly, the project demonstrates YAML in context—not simply as a file format, but as a foundational component of modern cloud, DevOps, automation, and CI/CD workflows.

For the complete implementation, configuration files, technical documentation, and supporting evidence:

🔗 YAML Learning Lab — GitHub Repository


Author

Rahimah Sulayman

Cloud & DevOps Engineer | Data Analyst

Top comments (2)

Collapse
 
rahimah_dev profile image
Rahimah Sulayman

YAML looks simple, but indentation is doing a lot of work behind the scenes. This lab is a great reminder that small syntax details can have a big impact in automation and DevOps workflows.

Collapse
 
rahimah_dev profile image
Rahimah Sulayman

What I particularly like about YAML is how quickly simple key-value pairs can evolve into real-world configurations for CI/CD, Kubernetes, and cloud automation. Great practical reference!