I have a dictionary structure that looks like the following:
myservers:
DC1:
CORE: 10.10.10.20
DMZ: 10.10.20.20
DC2:
CORE: 10.10.10.30.20
DMZ: 10.10.10.40.20
DC3:
CORE: 10.10.50.20
DMZ: 10.10.60.20
DC4:
CORE: 10.10.70.20
DMZ: 10.10.80.20
And another dictionary that looks like the following:
location:
address: 10.10.10.10
dc: DC1
net: 10.10.10.0
bits: 24
zone: CORE
I want to do something like the following:
- debug:
msg: “myserver = myservers[‘{{location.dc}}’][‘{{location.zone}}’]”
and get back the message:
myserver = 10.10.10.20
But instead, I get:
myserver = myservers[‘DC1’][‘CORE’]
I want to see the value stored at myservers[‘DC1’][‘CORE’], not the string “myservers[‘DC1’][‘CORE’]”.
I have tried " {{ myservers[‘{{location.dc}}’]['{{location.zone}}] }}", but YAML does not allow nested braces, so that fails. And I have tried many other variations, but they all fail too. I am stymied. How do I extract the information I want?