dhcpd/pf: Add DHCP failover support

This commit is contained in:
Timo Makinen 2025-06-22 17:52:29 +00:00
parent 97c9467b89
commit 5e803c87fb
2 changed files with 40 additions and 1 deletions

View file

@ -2,6 +2,28 @@
authoritative;
ddns-update-style none;
{% if network_interfaces[0].vlan == 30 %}
# failover config
{% for host in groups['dnagw_' + intdomain.split('.')[0]] %}
{% if host != inventory_hostname %}
failover peer "failover-peer" {
{% if inventory_hostname.split('.')[0][-2:] | int % 2 == 0 %}
secondary;
{% else %}
primary;
mclt 3600;
split 128;
{% endif %}
address {{ inventory_hostname }};
peer address {{ host }};
max-response-delay 60;
max-unacked-updates 10;
load balance max seconds 3;
}
{% endif %}
{% endfor %}
{% endif %}
# custom options
option arch code 93 = unsigned integer 16;
@ -47,7 +69,14 @@ subnet {{ intnet | ansible.utils.ipaddr('network') }} netmask {{ intnet | ansibl
use-host-decl-names on;
{% if network_interfaces[0].vlan == 30 %}
range {{ intnet | ansible.utils.ipaddr(100) | ansible.utils.ipaddr('address') }} {{ intnet | ansible.utils.ipaddr(200) | ansible.utils.ipaddr('address') }};
pool {
{% for host in groups['dnagw_' + intdomain.split('.')[0]] %}
{% if host != inventory_hostname %}
failover peer "failover-peer";
{% endif %}
{% endfor %}
range {{ intnet | ansible.utils.ipaddr(100) | ansible.utils.ipaddr('address') }} {{ intnet | ansible.utils.ipaddr(200) | ansible.utils.ipaddr('address') }};
}
{% endif %}
}