blob: 2a67a3712dd2aa1ff57ecc6cf51f127dc4aed398 [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
11{% for subnet in dhcpd_subnets %}
12subnet {{ subnet.subnet | ipaddr('network') }} netmask {{ subnet.subnet | ipaddr('netmask') }} {
13
14 # routing
15{% if subnet.routers is defined %}
16 option routers {{ subnet.routers }};
17{% else %}
18 option routers {{ subnet.subnet | ipaddr('next_usable') }};
19{% endif %}
20
21 # DNS/naming options
22 option domain-name-servers {{ subnet.dns_servers | join(", ") }};
23 option domain-name "{{ subnet.dns_search [0] }}";
24 option domain-search "{{ subnet.dns_search | join('", "') }}";
25
26{% if subnet.tftpd_server is defined %}
27 # tftpd options
28 filename "{{ subnet.pxe_filename | default(dhcpd_pxe_filename) }}";
29 next-server {{ subnet.tftpd_server }};
30
31{% endif %}
32{% if subnet.range is defined %}
33 range {{ subnet.range | ipaddr('next_usable') }} {{ subnet.range | ipaddr('last_usable') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070034{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070035}
36
Zack Williams9fc21d72020-11-22 22:36:54 -070037{% if subnet.hosts is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070038# hosts for subnet: {{ subnet.dns_search [0] }}
Zack Williams9fc21d72020-11-22 22:36:54 -070039{% for host in subnet.hosts %}
Zack Williamsbd970272020-11-30 22:59:00 -070040host {{ host.name }}.{{ subnet.dns_search [0] }} {
41 option host-name "{{ host.name }}";
42 fixed-address {{ host.ip_addr }};
43 hardware ethernet {{ host.mac_addr | hwaddr('linux') }};
Zack Williams9fc21d72020-11-22 22:36:54 -070044{% if host.pxe_filename is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070045 filename "{{ host.pxe_filename }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070046{% endif %}
47{% if host.default_url is defined %}
Zack Williamsbd970272020-11-30 22:59:00 -070048 option default-url "{{ host.default_url }}";
Zack Williams9fc21d72020-11-22 22:36:54 -070049{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070050}
Zack Williams9fc21d72020-11-22 22:36:54 -070051
52{% endfor %}
53{% endif %}
Zack Williamsbd970272020-11-30 22:59:00 -070054
Zack Williams9fc21d72020-11-22 22:36:54 -070055{% endfor %}