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