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/dhcpd.conf.j2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'roles/space_server/templates/dhcpd.conf.j2') diff --git a/roles/space_server/templates/dhcpd.conf.j2 b/roles/space_server/templates/dhcpd.conf.j2 index a2d82a7..13fc3ab 100644 --- a/roles/space_server/templates/dhcpd.conf.j2 +++ b/roles/space_server/templates/dhcpd.conf.j2 @@ -158,17 +158,17 @@ subnet 10.42.3.0 netmask 255.255.255.0 { group { use-host-decl-names on; ddns-updates off; -{% for host in local_hosts %} -{% if 'mac' in host and 'ipv4' in host %} +{% for name, info in local_hosts.items() %} +{% if 'mac' in info and 'ipv4' in info %} -{% if 'description' in host %} - # {{ host.description }} +{% if 'description' in info %} + # {{ info.description }} {% endif %} - host {{ host.name }} { - hardware ethernet {{ host.mac }}; - fixed-address {{ host.ipv4|join(', ') }}; -{% if 'filename' in host %} - filename "{{ host.filename }}"; + host {{ name }} { + hardware ethernet {{ info.mac }}; + fixed-address {{ info.ipv4|join(', ') }}; +{% if 'filename' in info %} + filename "{{ info.filename }}"; {% endif %} } {% endif %} -- cgit v1.2.1