Introduction to YAML
Introduction
YAML, previously known as Yet Another Markup Language, but now YAML Ain’t Markup Language, is a human friendly data serialization standard for programming languages.
YAML and JSON, JavaScript Object Notation, are related to each other, where YAML, according to YAML 1.2 specification, is a superset of JSON.
YAML supports using scalars, sequences, and mappings. A scalar is a string, a number, or boolean, a sequence is a list, and a mapping is a key/value pair.
YAML is commonly used by configuration files in open source tools and Ansible, a network automation tool, uses YAML to run its playbooks.
When it comes to YAML syntax, be aware of the following:
- Indentation matters!
- Tabs aren’t allowed
- Normally two spaces used when indenting
- A single YAML file may contain multiple documents
- Every document starts with three dashes
- YAML is case sensitive
Scalars
Scalars are single values. It can be a string, number, or a boolean value. Strings don’t need to be quoted, except for some special cases:
- The string starts with a special character
- !#%@&*`?|>{[ or –
- The string starts or ends with whitespace characters
- The string contains : or # character sequences
- The string ends with a Continue reading

