{%- set dhcp_prefixes = salt['pillar.get']("node:dhcp:server:prefixes", []) -%} {%- set dns_resolver_IP = salt["pillar.get"]("globals:dns:resolver_v4") -%} {%- set dns_search_domain = salt["pillar.get"]("globals:dns:search") -%} {%- set unifi_address = salt["pillar.get"]("globals:unifi:address") -%} # # DHCP server configuration (Salt managed) # authoritative; ddns-update-style none; log-facility local7; default-lease-time 600; max-lease-time 3600; option domain-name-servers {{ dns_resolver_IP }}; option space ubnt; option ubnt.unifi-address code 1 = ip-address; class "ubnt" { match if substring (option vendor-class-identifier, 0, 4) = "ubnt"; option vendor-class-identifier "ubnt"; vendor-option-space ubnt; } {% for prefix in dhcp_prefixes %} # {{ prefix["description"] }} subnet {{ prefix["network"] }} netmask {{ prefix["netmask"] }} { {#- We must only define a pool when there's at least one range for the subnet #} {%- if "ranges" in prefix %} pool { {%- endif %} {%- if not prefix.get("authoritative", True) %} not authoritative; {%- endif %} # monitor: 75% 90% Y {{ grains['nodename'] }}/{{ prefix["description"] }} # Use our own IP as gateway for our clients option routers {{ prefix["routers"] }}; {%- if prefix.get("role") == "mgmt" %} option ubnt.unifi-address 10.132.251.21; option domain-name "{{ dns_search_domain }}"; {%- endif %} {% if "ranges" in prefix %} # Range(s) of IPs to lease to clients {%- for range in prefix["ranges"] %} range {{ range }}; {%- endfor %} {%- else %} # No ranges defined, static leases only? {%- endif %} {%- if "ranges" in prefix %} } {%- endif %} } {% endfor %}