{%- import_yaml "netmasks.yaml" as netmasks -%} {%- for iface, ips in salt['grains.get']('ip_interfaces').items() %} {%- if iface not in ['core', 'lo'] %} {%- 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'] }}; range {{ conf['start'] }} {{ conf['end'] }}; {%- for name, value in conf['opts'].items() %} option {{ name }} {{ value }}; {%- endfor %} {%- for name, value in conf['host-opts'].items() %} {%- set host = value.split('.')[0] %} {%- set net = value.split('.')[1] %} option {{ name }} {{ pillar['hosts-inet'][net][host] }}; {%- endfor %} {%- for name, value in conf['string-opts'].items() %} option {{ name }} "{{ value }}"; {%- endfor %} } {%- endif %} {%- endfor %}