blob: 2ed342001558041737b2c8e8d05963f109833c83 [file] [log] [blame]
# dhcpd templates/dhcpd.conf.j2 - {{ ansible_managed }}
{#
SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
SPDX-License-Identifier: Apache-2.0
#}
# global lease options
default-lease-time {{ subnet.lease_time | default("240") }};
max-lease-time {{ subnet.max_lease_time | default("480") }};
{% for subnet in dhcpd_subnets %}
subnet {{ subnet.subnet | ipaddr('network') }} netmask {{ subnet.subnet | ipaddr('netmask') }} {
# routing
{% if subnet.routers is defined %}
option routers {{ subnet.routers }};
{% else %}
option routers {{ subnet.subnet | ipaddr('next_usable') }};
{% endif %}
# DNS/naming options
option domain-name-servers {{ subnet.dns_servers | join(", ") }};
option domain-name "{{ subnet.dns_search [0] }}";
option domain-search "{{ subnet.dns_search | join('", "') }}";
{% if subnet.tftpd_server is defined %}
# tftpd options
filename "{{ subnet.pxe_filename | default(dhcpd_pxe_filename) }}";
next-server {{ subnet.tftpd_server }};
{% endif %}
{% if subnet.range is defined %}
range {{ subnet.range | ipaddr('next_usable') }} {{ subnet.range | ipaddr('last_usable') }};
{% endif %}
{% if subnet.hosts is defined %}
# hosts
{% for host in subnet.hosts %}
host {{ host.name }} {
option host-name "{{ host.name }}";
fixed-address {{ host.ip_addr }};
hardware ethernet {{ host.mac_addr | hwaddr('linux') }};
{% if host.pxe_filename is defined %}
filename "{{ host.pxe_filename }}";
{% endif %}
{% if host.default_url is defined %}
option default-url "{{ host.default_url }}";
{% endif %}
}
{% endfor %}
{% endif %}
}
{% endfor %}