Matteo Scandolo | 3896c47 | 2017-08-01 13:31:42 -0700 | [diff] [blame] | 1 | {# |
| 2 | Copyright 2017-present Open Networking Foundation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | #} |
| 16 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 17 | # dhcpd.conf |
| 18 | # Managed by Ansible! |
| 19 | |
| 20 | {% if dns_search %} |
| 21 | option domain-name "{{ dns_search[0] }}"; |
| 22 | option domain-search "{{ dns_search | join('", "') }}"; |
| 23 | {% endif %} |
| 24 | |
| 25 | {% if dns_servers %} |
| 26 | option domain-name-servers {{ dns_servers | join(", ") }}; |
| 27 | {% endif %} |
| 28 | |
| 29 | {% for subnet in dhcpd_subnets %} |
| 30 | subnet {{ subnet.cidr | ipaddr('network') }} netmask {{ subnet.cidr | ipaddr('netmask') }} { |
| 31 | option routers {{ subnet.router | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 32 | range {{ subnet.cidr | ipaddr(subnet.dhcp_first | default("129")) | ipaddr('address') }} {{ subnet.cidr | ipaddr(subnet.dhcp_last | default("254")) | ipaddr('address') }}; |
| 33 | {% if subnet.dns_search is defined %} |
| 34 | option domain-name {{ subnet.dns_search [0] }}; |
| 35 | option domain-search {{ subnet.dns_search| join(", ") }}; |
| 36 | {% endif %} |
| 37 | {% if subnet.dns_servers is defined %} |
| 38 | option domain-name-servers {{ subnet.dns_servers | join(", ") }}; |
| 39 | {% endif %} |
| 40 | default-lease-time {{ subnet.lease_time | default("240") }}; |
| 41 | max-lease-time {{ subnet.max_lease_time | default("480") }}; |
| 42 | {% if subnet.pxe_filename is defined %} |
| 43 | filename "{{ subnet.pxe_filename }}"; |
| 44 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 45 | {% endif %} |
| 46 | {% if subnet.static_nodes is defined %} |
| 47 | # hosts from list: static_nodes |
| 48 | {% for node in subnet.static_nodes %} |
| 49 | host {{ node.name }} { |
| 50 | option host-name "{{ node.name }}"; |
| 51 | {% set host_ipaddr = (subnet.cidr | ipaddr(node.ipv4_last_octet) | ipaddr('address')) %} |
| 52 | fixed-address {{ host_ipaddr }}; |
Zack Williams | 6e1d816 | 2018-01-31 15:29:55 -0700 | [diff] [blame] | 53 | hardware ethernet {{ node.hwaddr | default(vtn_net_management_host_hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('linux') }}; |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 54 | {% if node.pxe_filename is defined %} |
| 55 | filename "{{ node.pxe_filename }}"; |
| 56 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 57 | {% endif %} |
| 58 | } |
| 59 | {% endfor %} |
| 60 | {% endif %} |
| 61 | {% if subnet.other_static is defined %} |
| 62 | {% for hostlist in subnet.other_static %} |
| 63 | # hosts from list: {{ hostlist }} |
| 64 | {% set nodes = vars[hostlist] %} |
| 65 | {% for node in nodes %} |
| 66 | host {{ node.name }} { |
| 67 | option host-name "{{ node.name }}"; |
| 68 | {% set host_ipaddr = (subnet.cidr | ipaddr(node.ipv4_last_octet) | ipaddr('address')) %} |
| 69 | fixed-address {{ host_ipaddr }}; |
Zack Williams | 6e1d816 | 2018-01-31 15:29:55 -0700 | [diff] [blame] | 70 | hardware ethernet {{ node.hwaddr | default(vtn_net_management_host_hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('linux') }}; |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 71 | {% if node.pxe_filename is defined %} |
| 72 | filename "{{ subnet.pxe_filename }}"; |
| 73 | next-server {{ subnet.tftp_server | default(subnet.cidr | ipaddr('1') | ipaddr('address')) }}; |
| 74 | {% endif %} |
| 75 | } |
| 76 | {% endfor %} |
| 77 | {% endfor %} |
| 78 | {% endif %} |
| 79 | } |
| 80 | |
| 81 | {% endfor %} |