Browse Source

dhcp-server: Use input from dhcp_server NACL module

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 3 weeks ago
parent
commit
89247b5720
2 changed files with 19 additions and 33 deletions
  1. 11 23
      dhcp-server/dhcpd.conf
  2. 8 10
      dhcp-server/dhcpd.default

+ 11 - 23
dhcp-server/dhcpd.conf

@@ -1,11 +1,7 @@
 #
 # Gateway DHCP server configuration (Salt managed)
 #
-{%- set sites = salt['pillar.get']('sites', {}) %}
-{%- set te = salt['pillar.get']('te', {}) %}
-{%- set node_config = salt['pillar.get']('nodes:' ~ grains['id']) %}
-{%- set te_prefixes = salt['ffho_net.get_te_prefixes'](te, grains['id'], 'v4') %}
-
+{%- set dhcp_prefixes = salt['pillar.get']("nodes:" ~ grains["id"] ~ ":dhcp:server:prefixes", []) %}
 # The ddns-updates-style parameter controls whether or not the server will
 # attempt to do a DNS update when a lease is confirmed. We default to the
 # behavior of the version 2 packages ('none', since DHCP v2 didn't
@@ -19,27 +15,19 @@ max-lease-time 3600;
 # Use Anycast DNS server(s)
 option domain-name-servers 10.132.251.53;
 
-{% for site in node_config.get ('sites', [])|sort %}
-  {%- set site_config = sites.get (site) %}
-  {%- set site_prefix = site_config.get ('prefix_v4') %}
-  {%- set brige_ips = salt['ffho_net.get_node_iface_ips'] (node_config, 'br-' ~ site) %}
-# {{ site }} / {{ site_config.get ('name') }}
-subnet {{ site_prefix.split ('/')[0] }} netmask {{ salt['ffho_net.cidr_to_dotted_mask'](site_prefix) }} {
+{% for prefix in dhcp_prefixes %}
+# {{ prefix["description"] }}
+subnet {{ prefix["network"] }} netmask {{ prefix["netmask"] }} {
 	pool {
-		# monitor: 75% 90% Y {{ grains['nodename'] }}/{{ site }} DHCP pool
+		# monitor: 75% 90% Y {{ grains['nodename'] }}/{{ prefix["description"] }} DHCP pool
 
-		# Use our own IP as gateway for our clients
-		option routers {{ brige_ips['v4'][0] }};
+		option routers {{ prefix["routers"] }};
 
-		# Range(s) of IPs to lease to clients
-  {%- for prefix in te_prefixes|sort %}
-    {%- if salt['ffho_net.is_subprefix'] (site_prefix, prefix) %}
-      {%- set prefix_config = te_prefixes.get (prefix) %}
-      {%- if 'dhcp_range' in prefix_config %}
-		range {{ prefix_config.get ('dhcp_range') }};
-      {%- endif %}
-    {%- endif %}
-  {%- endfor %}
+  {%- if "ranges" in prefix %}
+    {%- for range in prefix["ranges"] %}
+		range {{ range }};
+    {%- endfor %}
+  {%- endif %}
 	}
 }
 

+ 8 - 10
dhcp-server/dhcpd.default

@@ -1,16 +1,13 @@
-# Defaults for isc-dhcp-server initscript
-# sourced by /etc/init.d/isc-dhcp-server
-# installed at /etc/default/isc-dhcp-server by the maintainer scripts
-
-#
-# This is a POSIX shell fragment
-#
+{%- set dhcp_interfaces = salt['pillar.get']("nodes:" ~ grains["id"] ~ ":dhcp:server:ifaces", []) %}
+# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server) (Salt managed)
 
 # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
-#DHCPD_CONF=/etc/dhcp/dhcpd.conf
+#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
+#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
 
 # Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
-#DHCPD_PID=/var/run/dhcpd.pid
+#DHCPDv4_PID=/var/run/dhcpd.pid
+#DHCPDv6_PID=/var/run/dhcpd6.pid
 
 # Additional options to start dhcpd with.
 #	Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
@@ -18,4 +15,5 @@
 
 # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
 #	Separate multiple interfaces with spaces, e.g. "eth0 eth1".
-INTERFACES=""
+INTERFACESv4="{{ dhcp_interfaces|join(" ") }}"
+INTERFACESv6=""