YAML for DevOps part-3
Sahil Bhoyar
DevOps Engineer at Techfour Technology pvt ltd.| AWS | Git | GitHub | Docker | Kubernetes | Ansible | Jenkins | CI/CD | Terraform | Cloud | Linux | Automation | Maven | Sonarqube
On the 19th day, I learned the following things about YAML.
Write a sequence
---
student: !!seq
- mark
- name
- roll_no
...
Empty sequence will be called sparse sequence
---
sparse seq:
- how
- where
-
- Null
- sup
...
Write a nested sequence
---
-
- mango
- orange
- apple
-
- car
- truck
- bus
...
Key value pairs are called maps
!!map
Write nested mappings: map within a map
---
name: sahil bhoyar
roles:
age: 22
job: software engineer
...
same like this
---
name: sahil bhoyar
roles: {age: 22, job: software engineer}
...
Write pairs which means that one key may have multiple values
!!pairs
Example
---
pair example: !!pairs
- job: student
- job: teacher
...
Set will allow you to have unique values
---
names: !!set
? sahil
? sanket
? sarves
...
Write a dictionary that will represent sequence as a value
!!omap
Example
---
people:
- sahil:
name:sahil
age: 25
role: software engineer
- sanket:
name: sanket
age: 19
role: data scientist
...
Re-use some properties using anchors
likings: &fruitsChoice
like: mango
dislike: banana
person1:
name: sahil
<<: *fruitsChoice
person2:
name: sanket
<<: *fruitsChoice
person3:
name: sarvesh
<<: *fruitsChoice
Result
person1:
name: sahil
like: mango
dislike: banana
If you want to override some data. The data will be replaced with a new one
person1:
name: sahil
like: mango
<<: *fruitsChoice
dislike: orange
Example of multiple nested sequence
Schools:
- name: gcoe
principal: Someone
students:
- roll_no: 12
name: some person
marks: 5
so thats all about my today's learning
Happy learning : )
CEO & Co-Founder of Gart Solutions | Cloud Solutions Architect & Digital Transformation Consultant
1 年Great effort on the #60daysofdevops challenge! Can't wait to read your article on YAML for DevOps. ??