blob: 4839a8caa0f3d06bfbc6e42c690d749459f26f40 [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 Williams9fc21d72020-11-22 22:36:54 -070020 option routers {{ subnet.routers }};
Zack Williamsc1d528f2020-12-09 13:25:18 -070021 option rfc3442-classless-static-routes {{ subnet.subnet | ipaddr('prefix') }}, {{ subnet.subnet | ipaddr('network') | regex_replace('\.', ', ')}}, {{ subnet.routers | ipaddr('network') | regex_replace('\.', ', ')}};
Zack Williams9fc21d72020-11-22 22:36:54 -070022{% else %}
Zack Williamsc1d528f2020-12-09 13:25:18 -070023 # first IP address in range used as router
Zack Williams9fc21d72020-11-22 22:36:54 -070024 option routers {{ subnet.subnet | ipaddr('next_usable') }};
25{% endif %}
26
27 # DNS/naming options
28 option domain-name-servers {{ subnet.dns_servers | join(", ") }};
29 option domain-name "{{ subnet.dns_search [0] }}";
30 option domain-search "{{ subnet.dns_search | join('", "') }}";
31
32{% if subnet.tftpd_server is defined %}
33 # tftpd options
34 filename "{{ subnet.pxe_filename | default(dhcpd_pxe_filename) }}";
35 next-server {{ subnet.tftpd_server }};
36
37{% endif %}
38{% if subnet.range is defined %}
39 range {{ subnet.range | ipaddr('next_usable') }} {{ subnet.range | ipaddr('last_usable') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070040{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070041}
42
Zack Williams9fc21d72020-11-22 22:36:54 -070043{% if subnet.hosts is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070044# hosts for subnet: {{ subnet.dns_search [0] }}
Zack Williams9fc21d72020-11-22 22:36:54 -070045{% for host in subnet.hosts %}
Zack Williamsbd970272020-11-30 22:59:00 -070046host {{ host.name }}.{{ subnet.dns_search [0] }} {
47 option host-name "{{ host.name }}";
48 fixed-address {{ host.ip_addr }};
49 hardware ethernet {{ host.mac_addr | hwaddr('linux') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070050{% if host.pxe_filename is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070051 filename "{{ host.pxe_filename }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070052{% endif %}
53{% if host.default_url is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070054 option default-url "{{ host.default_url }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070055{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070056}
Zack Williams9fc21d72020-11-22 22:36:54 -070057
58{% endfor %}
59{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070060
Zack Williams9fc21d72020-11-22 22:36:54 -070061{% endfor %}