![Photo by Austin Neill on Unsplash Photo by Austin Neill on Unsplash](/var/ezflow_site/storage/images/archive/2022/68/configuring-complex-environments/photobyaustinneillonunsplash_cockpit.png/193396-1-eng-US/PhotobyAustinNeillonUnsplash_cockpit.png_medium.png)
Photo by Austin Neill on Unsplash
Configuring complex environments
At the Controls
The DevOps world without YAML [1] is difficult to imagine. In fact, YAML is a superset of JavaScript Object Notation (JSON) [2]. However, the focus of JSON is more on data serialization (e.g., to make data available to an API).
In contrast, YAML plays to its strengths when used as a configuration language because the format is more easily readable than JSON. Python programmers love YAML because, unlike JSON, it uses indentations instead of parentheses to define objects.
Basic YAML Syntax
Listing 1 shows a simple YAML document. The ---
string in the first line means a file can contain several such documents; it is then followed by typical key-value pairs, which are familiar if you have used JSON. The first key pair is a simple scalar with a string value, although numbers and booleans are also allowed. The list that follows is a collection of objects. In this case, only numeric values are used, each of which is indented with spaces.
Listing 1
YAML Objects
--- name: starwars collection year of publication: - 1977 - 1980 - 1983 movies: # Only movies from the original trilogy (OT) are listed here. ot: - Episode IV - A New Hope - Episode V - The Empire Strikes Back - "Episode VI - Return of the Jedi Knights."
You should avoid using tabs if possible because they can cause issues when processing the data. By the way, you do not have to write strings in parentheses, as shown in the final line of Listing 1. This collection of key-value pairs is a
...Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.
![Learn More”>
</a>
<hr>
</div>
</div>
<div class=](https://www.admin-magazine.com/var/ezflow_site/storage/images/media/images/learn-more/211417-1-eng-US/Learn-More.png)