diff --git a/salt/dhcp/default b/salt/dhcp/default index 2afae5d..689f7c2 100644 --- a/salt/dhcp/default +++ b/salt/dhcp/default @@ -1,6 +1,6 @@ {%- set ifaces = [] %} {%- for iface, ips in salt['grains.get']('ip_interfaces').items() %} -{%- if iface not in ['core', 'lo'] %} +{%- if iface not in ['core', 'lo'] and pillar['subnets-inet'].get(iface) %} {%- set ifaces = ifaces.append(iface) %} {%- endif %} {%- endfor %} diff --git a/salt/dhcp/dhcpd.conf b/salt/dhcp/dhcpd.conf index 93b5366..e594b79 100644 --- a/salt/dhcp/dhcpd.conf +++ b/salt/dhcp/dhcpd.conf @@ -1,7 +1,7 @@ {%- import_yaml "netmasks.yaml" as netmasks -%} {%- for iface, ips in salt['grains.get']('ip_interfaces').items() %} -{%- if iface not in ['core', 'lo'] %} +{%- 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]] }} { @@ -9,15 +9,15 @@ subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { default-lease-time {{ conf['time'] }}; max-lease-time {{ conf['max-time'] }}; range {{ conf['start'] }} {{ conf['end'] }}; -{%- for name, value in conf['opts'].items() %} +{%- for name, value in (conf.get('opts') or {}).items() %} option {{ name }} {{ value }}; {%- endfor %} -{%- for name, value in conf['host-opts'].items() %} +{%- 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['string-opts'].items() %} +{%- for name, value in (conf.get('string-opts') or {}).items() %} option {{ name }} "{{ value }}"; {%- endfor %} }