blob: bda9becc61cdb6d46bd9cb5b0f055a7cc45d72cb [file] [log] [blame]
Zack Williams9fc21d72020-11-22 22:36:54 -07001# dhcpd templates/dhcpd.conf.j2 - {{ ansible_managed }}
2{#
3SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
4SPDX-License-Identifier: Apache-2.0
5#}
6
7# global lease options
8default-lease-time {{ subnet.lease_time | default("240") }};
9max-lease-time {{ subnet.max_lease_time | default("480") }};
10
Zack Williamsc1d528f2020-12-09 13:25:18 -070011# option definitions
12option rfc3442-classless-static-routes code 121 = array of integer 8;
13
Zack Williams9fc21d72020-11-22 22:36:54 -070014{% for subnet in dhcpd_subnets %}
15subnet {{ subnet.subnet | ipaddr('network') }} netmask {{ subnet.subnet | ipaddr('netmask') }} {
16
17 # routing
18{% if subnet.routers is defined %}
Zack Williamsc1d528f2020-12-09 13:25:18 -070019 # custom router IP set
Zack Williams65ee5d02020-12-14 20:57:00 -070020 option routers {{ subnet.routers | map(attribute="ip") | join (",") }};
21{% for rtr in subnet.routers %}
22{% if "rfc3442routes" in rtr %}
23{% for r3442r in rtr.rfc3442routes %}
24 option rfc3442-classless-static-routes {{ r3442r | ipaddr('prefix') }}, {{ r3442r | ipaddr('network') | regex_replace('\.', ', ')}}, {{ rtr.ip | ipaddr('network') | regex_replace('\.', ', ')}};
25{% endfor %}
26{% endif %}
27{% endfor %}
Zack Williams9fc21d72020-11-22 22:36:54 -070028{% else %}
Zack Williamsc1d528f2020-12-09 13:25:18 -070029 # first IP address in range used as router
Zack Williams9fc21d72020-11-22 22:36:54 -070030 option routers {{ subnet.subnet | ipaddr('next_usable') }};
31{% endif %}
32
33 # DNS/naming options
34 option domain-name-servers {{ subnet.dns_servers | join(", ") }};
35 option domain-name "{{ subnet.dns_search [0] }}";
36 option domain-search "{{ subnet.dns_search | join('", "') }}";
37
38{% if subnet.tftpd_server is defined %}
39 # tftpd options
40 filename "{{ subnet.pxe_filename | default(dhcpd_pxe_filename) }}";
41 next-server {{ subnet.tftpd_server }};
42
43{% endif %}
44{% if subnet.range is defined %}
45 range {{ subnet.range | ipaddr('next_usable') }} {{ subnet.range | ipaddr('last_usable') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070046{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070047}
48
Zack Williams9fc21d72020-11-22 22:36:54 -070049{% if subnet.hosts is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070050# hosts for subnet: {{ subnet.dns_search [0] }}
Zack Williams9fc21d72020-11-22 22:36:54 -070051{% for host in subnet.hosts %}
Zack Williamsbd970272020-11-30 22:59:00 -070052host {{ host.name }}.{{ subnet.dns_search [0] }} {
53 option host-name "{{ host.name }}";
54 fixed-address {{ host.ip_addr }};
55 hardware ethernet {{ host.mac_addr | hwaddr('linux') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070056{% if host.pxe_filename is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070057 filename "{{ host.pxe_filename }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070058{% endif %}
59{% if host.default_url is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070060 option default-url "{{ host.default_url }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070061{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070062}
Zack Williams9fc21d72020-11-22 22:36:54 -070063
64{% endfor %}
65{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070066
Zack Williams9fc21d72020-11-22 22:36:54 -070067{% endfor %}