YAML Merge Keys
YAML merge keys use << with an anchor reference to merge another mapping's key-value pairs into the current mapping, providing inheritance/mixin within YAML documents.
Purpose
To reuse mapping content in YAML configuration, avoiding duplication and supporting configuration inheritance and composition.
Mechanism
Inside a mapping, <<: *anchor merges all key-value pairs of the anchor-referenced mapping into the current one; same-named keys in the current mapping win. Multiple references (list form) can be merged.
Use cases
- CI/CD configuration reuse
- Docker Compose service inheritance
- Ansible role mixins