Iterate Hash in template.

I am trying to iterate over a hash of hash of a list, but I do not seem to be having much luck, I have setup a group variable which I select using a variable, which appears to be working correctly as per the debug, but once in the template I don’t seem to be able to iterate over it no matter what permutations I use.

Any advice on this would be great.
Thanks
Dave

cat group_vars/all
boston:
nameservers: [‘10.0.0.1’,‘10.0.0.2’]
ntp: [‘pool1.ntp.org’,‘pool2.ntp.org’]
losangeles:
nameservers: [‘10.0.1.1’,‘10.0.1.2’]
ntp: [‘pool1.ntp.org’,‘pool2.ntp.org’]

cat main.yml

I managed to achieve this by using “hostvar” in my template is this the correct way to be referencing hashes in templates?

Thanks
Dave

{% for servers in hostvars[inventory_hostname][SITE][‘ntp’] %}
server {{servers}}
{% endfor %}

its correct way to reference most vars

Thanks for clarifying this Brian.

Dave