Skip to content

Instantly share code, notes, and snippets.

@davidlares
Last active October 6, 2023 13:56
Show Gist options
  • Save davidlares/7b6ecf91a241b6851777a10c446c556b to your computer and use it in GitHub Desktop.
Save davidlares/7b6ecf91a241b6851777a10c446c556b to your computer and use it in GitHub Desktop.
A basic YAML syntax review concept and implementation.

A basic YAML syntax review concepts

In a short note, YAML files represent configuration data in most of the times. According to Wikipedia: YAML "is a human-friendly data serialization standard for all programming languages". Basically we can say that is similar to XML and JSON notation and it is pretty used on DevOps activities for IaC configurations and for sharing data across multiple applications.

Features

  1. key-Value Pair: there's nothing more to say to this. You have a "Key" that acts as an Identification for value itself.

    Here's an example:

    Key: Value

  2. Array and Lists: is the same data structure, just like any programming language.

    Here's an example:

    Fruits:

    - Apple

    - Orange

    - Banana

  3. Dictionaries and Maps: it is a common data structure equivalent to a hash map

    Here's an example:

    Fruits:

    Cal : 104

    For this structure is very important the usage of blank spaces for hierarchy purposes (indentation)

    A typical dictionary example is a Car with multiple internal properties represented by Key-Value pair representation, but a Parking lot example is represented by a couple of dictionaries.

Final Notes

  1. Properties can be defined without any order
  2. For arrays, item order matter
  3. In case of having two dictionaries, they will be considered the same if their properties are equal without an order
  4. The # is for comments
# Dictionary
Employee:
# Key/Pair Value
Name: Jacob
Sex: Male
Age: 30
Title: Systems Engineer
#Array
Projects:
- Automation
- Support
# Array of Dictionaries
Payslips:
- Month: June
Wage: 4000
- Month: July
Wage: 4500
- Month: August
Wage: 4000
@f2ka07
Copy link

f2ka07 commented Mar 4, 2023

YAML is a powerful markup language (short for "YAML Ain't Markup Language") is a human-readable data serialization language that is commonly used in container technology. YAML is a lightweight and simple language that allows for easy configuration of containerized applications. YAML drives, container technology, and thanks to YAML NetDevOps was born.

In container technology, YAML files are used to define the configuration and settings for containerized applications. These files can be used to define the container's image, network settings, environment variables, volumes, and other important details. YAML files are often used in combination with container orchestration tools, such as Kubernetes or Docker Compose, to manage and deploy containerized applications across multiple nodes or hosts. These tools use YAML files to describe the desired state of the containerized application, and then orchestrate the deployment and management of the application based on that configuration.

YAML is a popular choice in container technology because of its simplicity and ease of use. It allows developers and system administrators to quickly and easily configure and manage containerized applications, making it an essential tool for container-based infrastructure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment