I have a file test.yml :
---
Servers:
Server1:
location: "Earth"
network: {ip: "0.0.0.0", mac: "00:00:00:00:00:00"}
inbound: "{{ Configs.Earth.allowed_connections }}"
Server2:
location: "Earth"
network: {ip: "0.0.0.1", mac: "00:00:00:00:00:02"}
inbound: "{{ Configs.Earth.allowed_connections }}"
Server3:
location: "Moon"
network: {ip: "0.0.0.2", mac: "00:00:00:00:00:02"}
Server4:
location: "Mars"
network: {ip: "0.0.0.3", mac: "00:00:00:00:00:03"}
inbound: "{{ Configs.Mars.allowed_connections }}"
Configs:
Earth:
allowed_connections:
- 99.99.99.99
- 99.99.99.98
- 99.99.99.97
Mars:
allowed_connections:
- 88.99.99.99
- 88.99.99.98
- 88.99.99.97
I'd like to resolve the inbound variables when I load the yml file with python. Is there a way to do this natively? Or will I need to write a function that searches for any variables containing "{{ }}" and then reset them.
The solution needs to allow for varying depths that the variables could be located at.
I have no issues loading the file with yaml.load it's the variable resolution I'm struggling with