blob: 14c4a6425f84341f87a1566ad0248b0414cd794c [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001{#
2Copyright 2017-present Open Networking Foundation
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15#}
16
Zack Williamsba5549c2017-03-25 15:04:45 -070017# dhcpd.conf
18# Managed by Ansible!
19
20{% if dns_search %}
21option domain-name "{{ dns_search[0] }}";
22option domain-search "{{ dns_search | join('", "') }}";
23{% endif %}
24
25{% if dns_servers %}
26option domain-name-servers {{ dns_servers | join(", ") }};
27{% endif %}
28
29{% for subnet in dhcpd_subnets %}
30subnet {{ 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 Williams6e1d8162018-01-31 15:29:55 -070053 hardware ethernet {{ node.hwaddr | default(vtn_net_management_host_hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('linux') }};
Zack Williamsba5549c2017-03-25 15:04:45 -070054{% 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 Williams6e1d8162018-01-31 15:29:55 -070070 hardware ethernet {{ node.hwaddr | default(vtn_net_management_host_hwaddr_prefix ~ (host_ipaddr | ip4_hex)) | hwaddr('linux') }};
Zack Williamsba5549c2017-03-25 15:04:45 -070071{% 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 %}