Skip to content

About

YAML Learning Lab is a hands-on project demonstrating YAML fundamentals through practical exercises and real-world configuration files.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

YAML Learning Lab

Overview

The YAML Learning Lab is a hands-on project that demonstrates the fundamentals of YAML through practical exercises. It covers key concepts such as key-value pairs, lists, nested structures, data types, comments, multi-line text, anchors, aliases, and GitHub Actions workflows. This project also demonstrates the use of Git for version control and serves as a practical portfolio of YAML skills used in Cloud and DevOps.

1. Create the project directory and navigate into it.

Command

mkdir -p yaml-learning-lab && cd yaml-learning-lab

2. Lesson 1: Basic Key-Value Structure (lesson1.yaml)

Concept: Shows how YAML stores simple information using key-value pairs.

Create the YAML File

cat > lesson1.yaml << 'EOF'
name: Samuel
role: Cloud Engineer
country: Nigeria
EOF

Verify the YAML File

Run:

cat lesson1.yaml

Output

name: samuel
role: Cloud Engineer
country: Nigeria

3. Lesson 2: nested Key-Value Structure (lesson2.yaml)

Concept: Introduces YAML nesting by grouping related information under a parent key.

Create the YAML File

cat > lesson2.yaml << 'EOF'
person:
  name: Samuel
  role: Cloud Engineer
EOF

Verify the YAML File

Run:

cat lesson2.yaml

Output

person:
  name: Samuel
  role: Cloud Engineer

Explanation

  • person is the parent key.
  • name and role are nested keys under person.
  • YAML uses spacing to show relationships between data.

4. Lesson 3: nested Configuration with Multiple Properties (lesson3.yaml)

Concept: Demonstrates how YAML groups multiple related properties under a single parent key.

Create the YAML File

cat > lesson3.yaml << 'EOF'
person:
  name: Samuel
  age: infant
  country: Nigeria
EOF

Verify the YAML File

Run:

cat lesson3.yaml

Output

person:
  name: Samuel
  age: infant
  country: Nigeria

Explanation

  • person is the parent key.
  • name, age, and country are child keys grouped under person.
  • The spacing shows that these properties all belong to the person section.
  • This structure is commonly used in configuration files to organize related data.

Verification of Lessons 1–3

The screenshot below shows the successful verification of the first three YAML lessons using the cat command in the VS Code terminal.

Verification of Lessons 1–3

5. Lesson 4: YAML List (lesson4.yaml)

Concept: Shows how YAML stores multiple values in a list using hyphens (-).

Create the YAML File

cat > lesson4.yaml << 'EOF'
skills:
  - Azure
  - Docker
  - Kubernetes
  - Git
EOF

Verify the YAML File

Run:

cat lesson4.yaml

Output

skills:
  - Azure
  - Docker
  - Kubernetes
  - Git

Explanation

  • skills is the main key.
  • Each item starting with - is a list item.
  • YAML uses hyphens (-) to represent multiple values under the same key.
  • Lists are commonly used to store items such as skills, tools, services, or servers.

6. Lesson 5: YAML List of Groups (lesson5.yaml)

Concept: Demonstrates how YAML stores multiple grouped records inside a single list.

Create the YAML File

cat > lesson5.yaml << 'EOF'
employees:
  - name: Samuel
    role: Cloud Engineer
  - name: Grace
    role: DevOps Engineer
  - name: Daniel
    role: Solution Architect
EOF

Verify the YAML File

Run:

cat lesson5.yaml

Output

employees:
  - name: Samuel
    role: Cloud Engineer
  - name: Grace
    role: DevOps Engineer
  - name: Daniel
    role: Solution Architect

Explanation

  • employees is the main key.
  • Each - starts a new employee record.
  • Every employee has two related pieces of information: name and role.
  • This format is useful when storing information about multiple people, servers, or applications in a single YAML file.

Screenshot

Verification of Lessons 4 and 5 in the VS Code Terminal

Verification of Lessons 4 and 5

7. Lesson 6: YAML Data Types (lesson6.yaml)

Concept: Demonstrates how YAML stores different types of data in a single configuration file.

Create the YAML File

cat > lesson6.yaml << 'EOF'
person:
  name: Samuel
  age: infant
  salary:30,000000
  active: true
  verified: false
  phone: null
  address:
    city: Port-harcourt
    country: Nigeria
EOF

Verify the YAML File

Run:

cat lesson6.yaml

Output

person:
  name: Samuel
  age: infant
  salary:30,000000
  active: true
  verified: false
  phone: null
  address:
    city: Port-harcourt
    country: Nigeria

Explanation

  • YAML supports different data types, making it useful for application and cloud configuration files.

8. Lesson 7: YAML Comments and Quoted Strings (lesson7.yaml)

Concept: Demonstrates how YAML uses comments to add notes and quotation marks to preserve text exactly as written.

Create the YAML File

cat > lesson7.yaml << 'EOF'
# Employee Information Configuration
city: Port harcourt
message: "Welcome: Cloud Engineers!"
EOF

Verify the YAML File

Run:

cat lesson7.yaml

Output

# Employee Information Configuration
city: Lagos
message: "Welcome: Cloud Engineers!"

Explanation

  • The line starting with # is a comment. It is ignored by YAML but helps explain the file.
  • city stores a text value.
  • message is enclosed in quotation marks to keep the text exactly as written.
  • Comments make YAML files easier to understand, especially when working with larger configuration files.

Screenshot 3

Verification of Lessons 6 and 7 in the VS Code Terminal

Verification of Lessons 6 and 7

9. YAML Anchors, Aliases, and Multiple Documents (anchors.yaml)

Concept: Demonstrates how YAML reuses common values with anchors and aliases, and how multiple YAML documents can be stored in a single file.

Create the YAML File

cat > anchors.yaml << 'EOF'
defaults: &default
  country: Nigeria
  role: Student

student1:
  <<: *default
  name: Samuel

student2:
  <<: *default
  name: Grace
---
name: Third Document Stream
EOF

Verify the YAML File

Run:

cat anchors.yaml

Output

defaults: &default
  country: Nigeria
  role: Student

student1:
  <<: *default
  name: Samuel

student2:
  <<: *default
  name: Grace
---
name: Third Document Stream

Explanation

  • &default creates an anchor, which saves a group of values for reuse.
  • *default is an alias that reuses the values stored in the anchor.
  • <<: copies the values from the anchor into another section.
  • student1 and student2 automatically inherit the country and role values from defaults.
  • --- marks the beginning of a new YAML document within the same file.
  • This approach helps reduce repetition and makes YAML files easier to maintain.

Screenshot 4

Verification of Lesson 8 (YAML Anchors, Aliases, and Multiple Documents) in the VS Code Terminal

Verification of YAML Anchors, Aliases, and Multiple Documents

10. GitHub Actions Workflow (workflow.yaml)

Concept: Demonstrates the basic structure of a GitHub Actions workflow used to automate tasks such as building, testing, and deploying applications.

Create the YAML File

cat > workflow.yaml << 'EOF'
name: Build Project

on:
  push:

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

Verify the YAML File

Run:

cat workflow.yaml

Output

name: Build Project

on:
  push:

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

Explanation

  • name gives the workflow a descriptive name.
  • on specifies when the workflow should run. In this example, it runs whenever code is pushed to the repository.
  • jobs contains the tasks the workflow will perform.
  • build is the name of the job.
  • runs-on specifies the operating system used to run the job. Here, it uses the latest Ubuntu runner provided by GitHub.
  • steps is a list of actions the job performs, one after another.
  • uses: actions/checkout@v4 downloads your repository's code so the workflow can access it.
  • run: echo "Building project..." executes a command in the runner and prints "Building project..." to the workflow log.
  • This is the foundation of a GitHub Actions workflow and is commonly used to automate software builds, tests, deployments, and other DevOps tasks.

Screenshot 5

Verification of Lesson 9 (GitHub Actions Workflow) in the VS Code Terminal

Verification of Lesson 9 - GitHub Actions Workflow

1️⃣1. Lesson 10: Multi-line Text (multiline.yaml)

Concept: Demonstrates how YAML stores text across multiple lines using the literal (|) and folded (>) styles.

Create the YAML File

cat > multiline.yaml << 'EOF'
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.
EOF

Verify the YAML File

Run:

cat multiline.yaml

Output

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.

Explanation

bio_literal: |

The pipe symbol (|) tells YAML to keep the text exactly as it is written, including line breaks.

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

When read by an application, the text remains:

I enjoy learning Azure.
I build cloud solutions.
I teach DevOps.

bio_folded: >

The greater-than symbol (>) tells YAML to combine multiple lines into a single paragraph.

bio_folded: >
  I enjoy learning Azure.
  I build cloud solutions.
  I teach DevOps.

When read by an application, it becomes:

I enjoy learning Azure. I build cloud solutions. I teach DevOps.

Why This Is Useful

  • Use | when you want to preserve line breaks.
  • Use > when you want multiple lines to be treated as one paragraph.
  • These styles are commonly used in Kubernetes manifests, GitHub Actions workflows, Docker Compose files, Ansible playbooks, and application configuration files.

Screenshot 6

Verification of Lesson 10 (Multi-line Text) in the VS Code Terminal

Verification of Lesson 10 - Multi-line Text

1️⃣2. Application Configuration (app-config.yaml)

Concept: Demonstrates how YAML organizes application settings into logical sections, making configuration files easy to read and manage.

Create the YAML File

cat > app-config.yaml << 'EOF'
application:
  name: SKILL.SCH
  version: 1.0

environment:
  name: Development

database:
  server: sql01
  port: 1433

logging:
  level: Information
EOF

Verify the YAML File

Run:

cat app-config.yaml

Output

application:
  name: SKILL.SCH
  version: 1.0

environment:
  name: Development

database:
  server: sql01
  port: 1433

logging:
  level: Information

Explanation

  • application groups information about the application.

    • name specifies the application's name.
    • version specifies the current version.
  • environment identifies where the application is running.

    • Development means the application is in a development environment. Other common environments include Testing, Staging, and Production.
  • database stores the database connection details.

    • server specifies the database server name.
    • port specifies the communication port. 1433 is the default port for Microsoft SQL Server.
  • logging controls how the application records events.

    • Information means the application logs general information about its operation.
  • The file is divided into sections, making it easier to locate and update configuration settings without affecting other parts of the application.

  • This type of YAML file is commonly used in cloud applications, web applications, APIs, Docker containers, Kubernetes deployments, and DevOps projects to separate configuration from application code.

Screenshot 7

Verification of Lesson 10 (Application Configuration) in the VS Code Terminal

Verification of Lesson 10 - Application Configuration

1️⃣2. Lesson 12: Complete YAML Student Profile (student-profile.yaml)

Concept: Combines the YAML concepts learned in previous lessons into one complete configuration file.

Create the YAML File

cat > student-profile.yaml << 'EOF'
default_profile: &default
  role: Student
  country: Nigeria
  active: true
  

name: Samuel
role: Cloud Engineer
country: Nigeria
city: port-harcourt

skills:
  - Azure
  - Docker
  - Kubernetes

hobbies:
  - Coding
  - Reading

address:
  street: Gra
  city: Port-harcourt
  country: Nigeria

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.

user1:
  <<: *default
  name: Grace

user2:
  <<: *default
  name: Daniel
EOF

Verify the YAML File

Run:

cat student-profile.yaml

Output

default_profile: &default
  role: Student
  country: Nigeria
  active: true


name: Samuel
role: Cloud Engineer
country: Nigeria
city: Port-harcourt

skills:
  - Azure
  - Docker
  - Kubernetes

hobbies:
  - Coding
  - Reading

address:
  street: Gra
  city: Port-harcourt
  country: Nigeria

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.

user1:
  <<: *default
  name: Grace

user2:
  <<: *default
  name: Daniel

Screenshot 8

Verification of Lesson 12 (Complete YAML Student Profile) in the VS Code Terminal

Verification of Lesson 12 - Complete YAML Student Profile

Key Concepts Learned

  • Basic key-value pairs
  • Grouped data (mappings)
  • Lists (sequences)
  • Nested structures
  • YAML data types
    • Strings (text)
    • Integers (whole numbers)
    • Floats (decimal numbers)
    • Booleans (true/false)
    • Null values (null)
  • Comments
  • Quoted strings
  • Multi-line text (| and >)
  • Anchors (&)
  • Aliases (*)
  • Merge keys (<<:)
  • Multiple YAML documents (---)
  • GitHub Actions workflow structure
  • Application configuration files

Version Control with Git

# 1. Initialize repository & add files
git init
git add .

# 2. Create commit
git commit -m "Complete YAML learning lab and student profile challenge"

# 3. Rename branch & push to remote
git branch -M main
git remote add origin <YOUR-GITHUB-REPO-URL>
git push -u origin main

Conclusion

The YAML Learning Lab provided a practical introduction to YAML through hands-on exercises and real-world examples. By completing each lesson, I gained confidence in creating, organizing, and validating YAML files while understanding their importance in Cloud and DevOps workflows.

What I Learned

Throughout this project, I learned how to:

  • Create basic key-value pairs.
  • Organize data using mappings and nested structures.
  • Work with lists and grouped records.
  • Use different YAML data types.
  • Add comments and quoted strings.
  • Write multi-line text using the | and > operators.
  • Reuse configuration with anchors and aliases.
  • Understand the structure of GitHub Actions workflow files.
  • Validate YAML files using Python.
  • Use Git for version control and publish a project to GitHub.

This project strengthened my understanding of YAML and its practical applications in tools such as GitHub Actions, Docker Compose, Kubernetes, Ansible, and other Cloud and DevOps technologies.

About

YAML Learning Lab is a hands-on project demonstrating YAML fundamentals through practical exercises and real-world configuration files.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors