From 876be1edaf9758bf35ec8b1f73fb32aa4ceaaa21 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Mon, 27 Sep 2021 13:28:26 +0200 Subject: space_server: vars: use dictionary for local_hosts This allows us to look up info on specific hosts without searching through the whole list. --- roles/space_server/templates/s.zone.j2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'roles/space_server/templates/s.zone.j2') diff --git a/roles/space_server/templates/s.zone.j2 b/roles/space_server/templates/s.zone.j2 index a392f3d..0394e98 100644 --- a/roles/space_server/templates/s.zone.j2 +++ b/roles/space_server/templates/s.zone.j2 @@ -8,17 +8,17 @@ labitrack.s. 600 IN A 185.38.175.70 labitrack.s. 600 IN AAAA 2a01:4262:1ab::cafe track.s. 600 IN A 185.38.175.70 track.s. 600 IN AAAA 2a01:4262:1ab::cafe -{% for host in local_hosts %} -{% if 'ipv4' in host or 'ipv6' in host %} +{% for name, info in local_hosts.items() %} +{% if 'ipv4' in info or 'ipv6' in info %} -{% if 'ipv4' in host %} -{% for ip in host.ipv4 %} -{{ host.name }}.s. 600 IN A {{ ip }} +{% if 'ipv4' in info %} +{% for ip in info.ipv4 %} +{{ name }}.s. 600 IN A {{ ip }} {% endfor %} {% endif %} -{% if 'ipv6' in host %} -{% for ip in host.ipv6 %} -{{ host.name }}.s. 600 IN AAAA {{ ip }} +{% if 'ipv6' in info %} +{% for ip in info.ipv6 %} +{{ name }}.s. 600 IN AAAA {{ ip }} {% endfor %} {% endif %} {% endif %} -- cgit v1.2.1