Zack Williams | 9fc21d7 | 2020-11-22 22:36:54 -0700 | [diff] [blame^] | 1 | # dhcpd templates/dhcpd.conf.j2 - {{ ansible_managed }} |
| 2 | {# |
| 3 | SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 4 | SPDX-License-Identifier: Apache-2.0 |
| 5 | #} |
| 6 | |
| 7 | # global lease options |
| 8 | default-lease-time {{ subnet.lease_time | default("240") }}; |
| 9 | max-lease-time {{ subnet.max_lease_time | default("480") }}; |
| 10 | |
| 11 | {% for subnet in dhcpd_subnets %} |
| 12 | subnet {{ 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') }}; |
| 34 | |
| 35 | {% endif %} |
| 36 | {% if subnet.hosts is defined %} |
| 37 | # hosts |
| 38 | {% for host in subnet.hosts %} |
| 39 | host {{ host.name }} { |
| 40 | option host-name "{{ host.name }}"; |
| 41 | fixed-address {{ host.ip_addr }}; |
| 42 | hardware ethernet {{ host.mac_addr | hwaddr('linux') }}; |
| 43 | {% if host.pxe_filename is defined %} |
| 44 | filename "{{ host.pxe_filename }}"; |
| 45 | {% endif %} |
| 46 | {% if host.default_url is defined %} |
| 47 | option default-url "{{ host.default_url }}"; |
| 48 | {% endif %} |
| 49 | } |
| 50 | |
| 51 | {% endfor %} |
| 52 | {% endif %} |
| 53 | } |
| 54 | {% endfor %} |