From d56dbc9412e687c36b4f2727aa2e416f8e18946e Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 17 Nov 2020 12:48:09 +0100 Subject: [PATCH] dhcpd: implement fixed-hosts capability --- salt/dhcp/dhcpd.conf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/salt/dhcp/dhcpd.conf b/salt/dhcp/dhcpd.conf index 153468a..3a1efea 100644 --- a/salt/dhcp/dhcpd.conf +++ b/salt/dhcp/dhcpd.conf @@ -1,10 +1,10 @@ {%- import_yaml "netmasks.yaml" as netmasks -%} - {%- for iface, ips in salt['grains.get']('ip_interfaces').items() %} {%- if iface not in ['core', 'lo'] and pillar['subnets-inet'].get(iface) %} +group { {%- set conf = pillar['dhcp'][iface] %} {%- set subnet = pillar['subnets-inet'][iface] %} -subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { + subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { authoritative; default-lease-time {{ conf['time'] }}; max-lease-time {{ conf['max-time'] }}; @@ -24,6 +24,12 @@ subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { {%- for name, value in (conf.get('string-opts') or {}).items() %} option {{ name }} "{{ value }}"; {%- endfor %} + } + +{%- for addr, hwaddr in (conf.get('fixed-hosts') or {}).items() %} + host {{ addr }} { hardware ethernet {{ hwaddr }}; } +{%- endfor %} + } {%- endif %} {%- endfor %}