Clearly I am missing something (obvious?) here :-( Dictionary is correctly resolved as var in debug, but I can't get it into a message (msg). How do I trigger interpolation in this case correctly? (The actual usecase is not debug, but this is a most simple example I could construct).
---
- name: Setup based on subnet
hosts:
- localhost
vars:
siteVars:
10.128.0.0:
ServerName: "AServ"
10.0.0.0:
ServerName: "BServ"
tasks:
- name: Do we get the right Network
debug:
msg: "{{ ansible_default_ipv4.network }}"
- name: Var works
debug:
var: siteVars[ {{ 'ansible_default_ipv4.network' }} ].ServerName
- name: Msg does not work interpolate
debug:
msg: "siteVars[ {{ 'ansible_default_ipv4.network' }} ].ServerName"
Gives:
TASK [Do we get the right Network] ******************************************************************************************ok: [localhost] => {
"msg": "10.0.0.0"
}
TASK [Var works] ******************************************************************************************ok: [localhost] => {
"siteVars[ ansible_default_ipv4.network ].ServerName": "BServ"
}
TASK [Msg does not work interpolate] ******************************************************************************************ok: [localhost] => {
"msg": "siteVars[ ansible_default_ipv4.network ].ServerName"
}