YAML is used for configuration by many technologies as it's easier and cleaner to read and write than JSON / XML.
Worth a read:
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
https://spacelift.io/blog/yaml
https://www.educative.io/blog/advanced-yaml-syntax-cheatsheet
Always lint your YAML to catch otherwise hard to spot whitespace errors such as inconsistent indentation or tabs vs spaces.
I use YAMLLint which is automatically installed by DevOps-Bash-tools
and you can run the check_yaml.sh
script in that repo to recurse the current or given directory and check all the YAML files.
I run this automatically in all my GitHub repos via CI/CD.
Use &
prefix anchor to mark a section and *
to reference to it later in the same YAML to reduce duplication.
Prefix the *<name>
reference with <<:
to allow you to add more fields underneath it. Same name fields are overridden.