network/salt/dhcp/dhcpd.conf

40 lines
1.4 KiB
ISCdhcpd
Raw Normal View History

2016-11-09 00:23:58 +01:00
{%- import_yaml "netmasks.yaml" as netmasks -%}
{%- for iface, ips in salt['grains.get']('ip_interfaces').items() %}
2016-12-15 19:11:07 +01:00
{%- if iface not in ['core', 'lo'] and pillar['subnets-inet'].get(iface) %}
group {
2020-11-17 12:55:11 +01:00
{%- set conf = pillar['dhcp'][iface] %}
2016-11-09 00:23:58 +01:00
default-lease-time {{ conf['time'] }};
max-lease-time {{ conf['max-time'] }};
2020-11-17 12:55:11 +01:00
{%- if conf.get('lower-max-time') and conf.get('time') %}
2016-12-16 00:01:06 +01:00
min-lease-time {{ conf['time'] }};
adaptive-lease-time-threshold {{ conf['lower-max-time'] }};
2020-11-17 12:55:11 +01:00
{%- endif %}
2016-12-15 19:11:07 +01:00
{%- for name, value in (conf.get('opts') or {}).items() %}
2016-11-09 00:23:58 +01:00
option {{ name }} {{ value }};
{%- endfor %}
2016-12-15 19:11:07 +01:00
{%- for name, value in (conf.get('host-opts') or {}).items() %}
2016-11-16 01:17:28 +01:00
{%- set host = value.split('.')[0] %}
{%- set net = value.split('.')[1] %}
option {{ name }} {{ pillar['hosts-inet'][net][host] }};
{%- endfor %}
2016-12-15 19:11:07 +01:00
{%- for name, value in (conf.get('string-opts') or {}).items() %}
2016-11-14 23:44:13 +01:00
option {{ name }} "{{ value }}";
{%- endfor %}
2020-11-17 12:55:11 +01:00
{%- 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() %}
2021-02-10 22:36:35 +01:00
host {{ addr }} {
hardware ethernet {{ hwaddr }};
fixed-address {{ addr }};
}
{%- endfor %}
2016-11-09 00:23:58 +01:00
}
{%- endif %}
{%- endfor %}