Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 1 | # dhcpd.conf |
| 2 | # Managed by Ansible! |
| 3 | |
| 4 | {% if dns_search %} |
| 5 | option domain-name "{{ dns_search[0] }}"; |
| 6 | option domain-search "{{ dns_search | join('", "') }}"; |
| 7 | {% endif %} |
| 8 | |
| 9 | {% if dns_servers %} |
| 10 | option domain-name-servers {{ dns_servers | join(", ") }}; |
| 11 | {% endif %} |
| 12 | |
| 13 | {% for subnet in dhcpd_subnets %} |
| 14 | subnet {{ subnet.cidr | ipaddr('network') }} netmask {{ subnet.cidr | ipaddr('netmask') }} { |
| 15 | option routers {{ subnet.router | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 16 | range {{ subnet.cidr | ipaddr(subnet.dhcp_first | default("129")) | ipaddr('address') }} {{ subnet.cidr | ipaddr(subnet.dhcp_last | default("254")) | ipaddr('address') }}; |
| 17 | {% if subnet.dns_search is defined %} |
| 18 | option domain-name {{ subnet.dns_search [0] }}; |
| 19 | option domain-search {{ subnet.dns_search| join(", ") }}; |
| 20 | {% endif %} |
| 21 | {% if subnet.dns_servers is defined %} |
| 22 | option domain-name-servers {{ subnet.dns_servers | join(", ") }}; |
| 23 | {% endif %} |
| 24 | default-lease-time {{ subnet.lease_time | default("240") }}; |
| 25 | max-lease-time {{ subnet.max_lease_time | default("480") }}; |
| 26 | {% if subnet.pxe_filename is defined %} |
| 27 | filename "{{ subnet.pxe_filename }}"; |
| 28 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 29 | {% endif %} |
| 30 | {% if subnet.static_nodes is defined %} |
| 31 | # hosts from list: static_nodes |
| 32 | {% for node in subnet.static_nodes %} |
| 33 | host {{ node.name }} { |
| 34 | option host-name "{{ node.name }}"; |
| 35 | {% set host_ipaddr = (subnet.cidr | ipaddr(node.ipv4_last_octet) | ipaddr('address')) %} |
| 36 | fixed-address {{ host_ipaddr }}; |
| 37 | hardware ethernet {{ node.hwaddr | default(hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('unix') }}; |
| 38 | {% if node.pxe_filename is defined %} |
| 39 | filename "{{ node.pxe_filename }}"; |
| 40 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 41 | {% endif %} |
| 42 | } |
| 43 | {% endfor %} |
| 44 | {% endif %} |
| 45 | {% if subnet.other_static is defined %} |
| 46 | {% for hostlist in subnet.other_static %} |
| 47 | # hosts from list: {{ hostlist }} |
| 48 | {% set nodes = vars[hostlist] %} |
| 49 | {% for node in nodes %} |
| 50 | host {{ node.name }} { |
| 51 | option host-name "{{ node.name }}"; |
| 52 | {% set host_ipaddr = (subnet.cidr | ipaddr(node.ipv4_last_octet) | ipaddr('address')) %} |
| 53 | fixed-address {{ host_ipaddr }}; |
| 54 | hardware ethernet {{ node.hwaddr | default(hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('unix') }}; |
| 55 | {% if node.pxe_filename is defined %} |
| 56 | filename "{{ subnet.pxe_filename }}"; |
| 57 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 58 | {% endif %} |
| 59 | } |
| 60 | {% endfor %} |
| 61 | {% endfor %} |
| 62 | {% endif %} |
| 63 | } |
| 64 | |
| 65 | {% endfor %} |