YAML
Blog
In Ansible , you can define variables in a variety of places, including inventory files, playbook files, and role defaults and vars files. When defining variables, you can use YAML anchors and aliases to reduce repetition and make your code more readable.
1
2
3
4
5
6
7
8
9
10
vars:
# Define an anchor called "common_vars"
common_vars: &common_vars
version: 2.0
name: My Application
# Define a variable that uses the "common_vars" anchor and adds additional information
prod_vars: &prod_vars
<<: *common_vars
environment: production