Learning Ansible 2.7(Third Edition)
上QQ阅读APP看书,第一时间看更新

YAML

YAML, like many other data serialization languages (such as JSON), has very few, basic concepts:

  • Declarations
  • Lists
  • Associative arrays

A declaration is very similar to a variable in any other language, which is as follows:

name: 'This is the name'

To create a list, we will have to use -:

- 'item1' 
- 'item2'
- 'item3'

YAML uses indentation to logically divide parents from children. So, if we want to create associative arrays (also known as objects), we would just need to add an indentation:

item: 
name: TheName
location: TheLocation

Obviously, we can mix those together as follows:

people:
- name: Albert
number: +1000000000
country: USA
- name: David
number: +44000000000
country: UK

Those are the basics of YAML. YAML can do much more, but for now, this will be enough.