{%- 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) %} {%- set conf = pillar['dhcp'][iface] %} {%- set subnet = pillar['subnets-inet'][iface] %} subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { authoritative; default-lease-time {{ conf['time'] }}; max-lease-time {{ conf['max-time'] }}; {%- if conf.get('lower-max-time') and conf.get('time') %} min-lease-time {{ conf['time'] }}; adaptive-lease-time-threshold {{ conf['lower-max-time'] }}; {%- endif %} range {{ conf['start'] }} {{ conf['end'] }}; {%- for name, value in (conf.get('opts') or {}).items() %} option {{ name }} {{ value }}; {%- endfor %} {%- for name, value in (conf.get('host-opts') or {}).items() %} {%- set host = value.split('.')[0] %} {%- set net = value.split('.')[1] %} option {{ name }} {{ pillar['hosts-inet'][net][host] }}; {%- endfor %} {%- for name, value in (conf.get('string-opts') or {}).items() %} option {{ name }} "{{ value }}"; {%- endfor %} } {%- endif %} {%- endfor %}