I am reverse-engineering and refactoring ansible code from a developer who has since left the company. In our ansible-vault file, I would love to know what the following items mean and how they add function/value to the yaml--I can't find any documentation in my search: "base: &base" "<<: *base"
Here is my sanitized vault yaml
---
secrets:
zk:
password: sdsfl34hgf
admin:
password: ldfk43277k
credentials:
base: &base
host: "{{ansible_host}}"
timeout: 30
transport: cli
svc_rhelsystemro:
<<: *base
username: svc_rhelsystemro
password: sdsfl34hgf
svc_rhelsystemrw:
<<: *base
username: svc_rhelsystemrw
password: ldfk43277k
svc_Network_Automation:
username: svc_Network_Automation
password: slk32sd@#$%h
Hopefully you were able to find your answer by now, but I'll post it here for anyone else looking for the same info.
What you are seeing are YAML anchors: https://docs.ansible.com/ansible/latest/user_guide/playbooks_advanced_syntax.html#yaml-anchors-and-aliases-sharing-variable-values.
I haven't personally used this functionality, but it essentially allows you to define aliases for complicated structures. In your example base.host
, base.timeout
, and base.transport
can all be referenced at the same time using the *base
alias.