YAML Anchors
YAML anchors mark nodes with &name and reference them with *name, enabling node reuse (aliases) within a YAML document.
Purpose
To define a node once and reference it many times in a YAML document, reducing duplicated configuration.
Mechanism
&anchor defines an anchor name before a node, and *anchor references the same node elsewhere (a shared reference—changing it once changes it everywhere). Anchor scope is the whole document.
Use cases
- CI/CD matrix reuse
- Docker Compose volume reuse
- Configuration DRY