From 9f5a35361a30e4e76d815cc1a890cbe6f1dd4a44 Mon Sep 17 00:00:00 2001 From: Igor Chudov Date: Tue, 20 Aug 2019 14:14:01 +0400 Subject: [PATCH] Declare hosts in corressponding subnets It is expected to allow to have different IP addresses for the same MAC based on subnet it is trying to boot in. --- roles/dhcp/templates/dhcpd.conf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/roles/dhcp/templates/dhcpd.conf b/roles/dhcp/templates/dhcpd.conf index e305617..a5595b4 100644 --- a/roles/dhcp/templates/dhcpd.conf +++ b/roles/dhcp/templates/dhcpd.conf @@ -50,14 +50,6 @@ subnet {{addr}} netmask {{n|ipaddr('netmask')}} { {% if dhcp.networks is defined %} {% for addr,net in dhcp.networks.iteritems() %} -{% if net.hosts is defined %} -{% for h in net.hosts %} -host {{net.vlan}}-{{h.name}} { - hardware ethernet {{h.mac}}; - fixed-address {{h.ipv4}}; -} -{% endfor %} -{% endif %} subnet {{addr.split('/')[0]}} netmask {{addr|ipaddr('netmask')}} { option routers {{net.default}}; @@ -69,6 +61,16 @@ subnet {{addr.split('/')[0]}} netmask {{addr|ipaddr('netmask')}} { next-server {{net.pxe['next-server']}}; filename "{{net.pxe.filename}}"; {% endif %} + +{% if net.hosts is defined %} +{% for h in net.hosts %} + host {{net.vlan}}-{{h.name}} { + hardware ethernet {{h.mac}}; + fixed-address {{h.ipv4}}; + } +{% endfor %} +{% endif %} + pool { range {{net.range}}; }