YAML setting value from another key
Accepted answer is wrong. It might have worked for the author for app specific reason but it is not supported by YAML specs. The correct way to reuse values in yaml is through something called anchors, like this
x1: &my_anchor
y: 'my val'
x2:
<<: *my_anchor
z: 3
In above, we mark the values in x1
using anchor my_anchor
. Then the special syntax <<: *my_anchor
tells YAML parser to insert children of the node (in this case y
) in the same level. So x2
will now have two children: y
and z
.