80 lines
2.2 KiB
Django/Jinja
80 lines
2.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";
|
|
}
|
|
}
|
|
}
|
|
|
|
# kludge to try to detect openbsd installer
|
|
class "OpenBSD" {
|
|
match if not exists vendor-class-identifier and not exists user-class;
|
|
|
|
next-server 172.20.20.10;
|
|
filename "auto_install";
|
|
option tftp-server-name "boot.foo.sh/openbsd";
|
|
}
|
|
|
|
shared-network FOOSH {
|
|
|
|
subnet 172.20.20.0 netmask 255.255.252.0 {
|
|
default-lease-time 86400;
|
|
max-lease-time 604800;
|
|
option subnet-mask 255.255.252.0;
|
|
option broadcast-address 172.20.23.255;
|
|
option routers 172.20.20.1;
|
|
|
|
option domain-name "home.foo.sh";
|
|
option domain-name-servers 172.20.20.10, 172.20.21.1, 172.20.21.2;
|
|
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 %}
|
|
|
|
}
|