network/salt/dhcp/dhcpd.conf

40 lines
1.4 KiB
ISCdhcpd

{%- 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) %}
group {
{%- set conf = pillar['dhcp'][iface] %}
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 %}
{%- 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 %}
{%- set subnet = pillar['subnets-inet'][iface] %}
subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} {
authoritative;
range {{ conf['start'] }} {{ conf['end'] }};
}
{%- for addr, hwaddr in (conf.get('fixed-hosts') or {}).items() %}
host {{ addr }} {
hardware ethernet {{ hwaddr }};
fixed-address {{ addr }};
}
{%- endfor %}
}
{%- endif %}
{%- endfor %}