DEV Community

Karl Esi
Karl Esi

Posted on

YAML for DevOps.

YAML has become very popular for writing configuration files. It has become a widely used format for writing configurations for many different DevOps tools and applications e.g. Docker, Kubernetes, Ansible, Prometheus.

For that reason while utilizing this instruments, understanding the subtleties of YAML language structure and its primary concepts is significant.

YAML is a data serialization language. Just like XML and JSON.

What is a Serialization language?

With a serialization language, applications written in different languages and with different technologies can exchange data using a common agreed upon or standard format. The most standard formats are YAML, JSON, and XML.

YAML actually stands for YAML Ain't Markup Language.

YAML files can be created with the extension:
.yaml
.yml

They are both the same.

YAML Format compared to others.

YAML has grown in popularity over the past years due to:
Because it is super human readable and intuitive, it is perfect for writing configuration files for all those recent DevOps tools like Docker, Kubernetes, etc.

We'll consider this example to show you how YAML, XML, and JSON formats compare. Here's how YAML looks:

YAML format sample

It's straightforward, and very clean.

Here is the same data in XML:

XML format sample

Here is the same code in JSON format:

Image description

The YAML encoding is a superset of the JSON encoding. Any valid JSON file can be encoded in YAML.

XML and JSON data structures are defined using special characters, as you have seen.

In XML, you have text in angle brackets <> while in JSON you have text in curly brackets {}. In YAML, you do not have those special characters.

How are data structures defined in YAML? It is defined through line separations and spaces with indentation.

That's why you can space and indent in JSON and XML, but not in YAML.

YAML format error sample

See you soon.

Top comments (0)