67 lines
2 KiB
Django/Jinja
67 lines
2 KiB
Django/Jinja
|
|
authoritative;
|
|
ddns-update-style none;
|
|
|
|
# custom options
|
|
option arch code 93 = unsigned integer 16;
|
|
|
|
# logging
|
|
on commit {
|
|
log(info,
|
|
concat("Client ",
|
|
binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)),
|
|
" requests ",
|
|
binary-to-ascii(16, 8, ":", option dhcp-parameter-request-list),
|
|
" - ",
|
|
pick-first-value(option vendor-class-identifier, "no vendor-id"),
|
|
" - ",
|
|
pick-first-value(option user-class, "no user-class"))
|
|
);
|
|
}
|
|
|
|
# pxe clients
|
|
class "PXEClient" {
|
|
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
|
|
|
|
next-server 172.20.20.10;
|
|
if exists user-class and option user-class = "iPXE" {
|
|
filename "https://boot.foo.sh/boot.ipxe";
|
|
} else {
|
|
if option arch = 00:07 {
|
|
filename "ipxe.efi";
|
|
} else {
|
|
filename "undionly.kpxe";
|
|
}
|
|
}
|
|
}
|
|
|
|
subnet {{ intnet_prefix }}.0 netmask {{ intnet_netmask }} {
|
|
default-lease-time 86400;
|
|
max-lease-time 604800;
|
|
option subnet-mask {{ intnet_netmask }};
|
|
#option broadcast-address 172.20.23.255;
|
|
option routers {{ intnet_prefix }}.1;
|
|
|
|
option domain-name "{{ inventory_hostname.split('.')[1] }}.foo.sh";
|
|
option domain-name-servers {{ intnet_prefix }}.10, {{ intnet_prefix }}.11, {{ intnet_prefix }}.12;
|
|
use-host-decl-names on;
|
|
}
|
|
|
|
{% for hostname in hostvars %}
|
|
{% if hostvars[hostname]['network_interfaces'] is defined %}
|
|
{% for interface in hostvars[hostname]['network_interfaces'] %}
|
|
{% if interface['vlan'] == 20 and interface['mac'] is defined %}
|
|
{% if interface['ipaddr'] is defined %}
|
|
{% set ipaddr = interface['ipaddr'] %}
|
|
{% else %}
|
|
{% set ipaddr = '172.20.21.' + interface['mac'].split(':')[5] | int(base=16) | string %}
|
|
{% endif %}
|
|
host {{ hostname }} {
|
|
option host-name "{{ hostname }}";
|
|
hardware ethernet {{ interface['mac'] }};
|
|
fixed-address {{ ipaddr }};
|
|
}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endfor %}
|