YAML, or YAML Ain’t Markup Language, is a human-readable data serialisation language just like XML and JSON, it is often used to write configuration files. YMAL files have two extensions .yaml
or .yml
.
YAML data structure is defined using line separation and indentation, all YAML files can optionally start with ---
and end with ...
.
Data types
String String can be in double quotation marks (” ”), single quotation marks (’ ’), or no quotation marks
Boolean
YAML indicates boolean values with the keywords True
, On
and Yes
for true. False is indicated with False
, Off
, or No
.
Dictionary
A dictionary is represented in a key value pair form (key: value
), the colon must be followed by a space.
List
List contains multiple values, all members of a list are lines at the same indentation level, starting with a dash (-
) and followed by a space.
Multiple lines value
Values can span multiple lines using |
or >
. “Literal Block Scalar” |
will include the newlines and any trailing spaces, preserve the exact value. Using a “Folded Block Scalar” >
will fold newlines to spaces;
The value of include_newlines
and fold_newlines
would be:
exactly as you see
will appear these three
lines of poetry
this is really a single line of text despite appearances
start a new line
Additional indicators
|-
or>-
: Strip the final newline.|+
or>+
: Preserve the final newline.|
or>
: (without any additional indicators) keeps the final newline.
Back to parent page: DevOps