YAML or YML has become a must know data serialization language for System Administrators, it is widely used in many of the configuration management, containerization platforms , Orchestration applications, Infra as a Code, and many more, and because of it's human readable formats, it's widely accepted and used.
YAML usage in some widely used sysadmin tools.- Ansible
- Docker
- Kubernetes
- AWS CloudFormation.
- TerraForm
Here in this blog post, i have kept some of the YAML cheat sheets, which can help you to craft your own or to read some yaml files.
- Ansible
- Docker
- Kubernetes
- AWS CloudFormation.
- TerraForm
Key Value
A variety of data is structured in the form of key value pairs.
Key - Items written on left side of data ( Fruit, Drink, Vegetable )
Value - Items written on left side of data ( Orange, Juice, Spinach)
Important: Space after :
YAML Key Value Pair Fruit: Orange
Drink: Juice
Vegetable: Spinach
Fruit: Orange
Drink: Juice
Vegetable: Spinach
List or Array
A representation of List Smartphone type and Brand type in YAML format.
YAML List/Array Smartphones: - IOS
- Android
Brands:
- Apple
- Nokia
- Micromax - Vivo
Smartphones:
- IOS
- Android
Brands:
- Apple
- Nokia
- Micromax - Vivo
Dictionary
A representation of Employee named 26 year old male named as Jignesh working as Web developer data in dictionary type in YAML format.
YAML Dictionary/Map Employee:
Name: Jignesh
Sex: Male
Age: 26
Title: Web Developer
Employee:
Name: Jignesh
Sex: Male
Age: 26
Title: Web Developer
Dictionary inside List
A representation of multiple list of Fruits (Mango, Guava, Banana) and their individual specification mapped in dictionary value ( Calories, Fat, Carbs )
YAML Dictionary inside List Fruits:
- Mango:
Calories: 95
Fat: 0.3
Carbs: 25
- Guava:
Calories: 105
Fat: 0.4
Carbs: 27
- Banana:
Calories: 45
Fat: 0.1
Carbs: 11
Vegetables:
- Onion:
Calories: 25
Fat: 0.1
Carbs: 6
- Potato:
Calories: 22
Fat: 0.2
Carbs: 4.8
- Ginger:
Calories: 8
Fat: 0.1
Carbs: 1.9
Fruits:
- Mango:
Calories: 95
Fat: 0.3
Carbs: 25
- Guava:
Calories: 105
Fat: 0.4
Carbs: 27
- Banana:
Calories: 45
Fat: 0.1
Carbs: 11
Vegetables:
- Onion:
Calories: 25
Fat: 0.1
Carbs: 6
- Potato:
Calories: 22
Fat: 0.2
Carbs: 4.8
- Ginger:
Calories: 8
Fat: 0.1
Carbs: 1.9
List inside Dictionary
A representation of Employee named 26 year old male named as Jignesh working as Web developer data in dictionary type.
Employee Shail has been assigned two Projects ( Login and Logout Form ), a representation of List data.
YAML List inside Dictionary Employee:
Name: Shail
Sex: Male
Age: 28
Title: Web Developer Projects: - Login Form
- Logout Form
Employee:
Name: Shail
Sex: Male
Age: 28
Title: Web Developer
Projects:
- Login Form
- Logout Form