ifstated: Fix dna conf to work on all hosts

This commit is contained in:
Timo Makinen 2025-06-18 04:47:44 +00:00
parent fbf3d56f79
commit 8ebceed305

View file

@ -16,7 +16,7 @@ state auto {
state master { state master {
init { init {
# spoof mac to keep dhcp lease in sync with both gw's # spoof mac to keep dhcp lease in sync with both gw's
run "/sbin/ifconfig vio1 lladdr {{ gw_home_mac }} up" run "/sbin/ifconfig vio1 lladdr {{ lookup('vars', 'gw_mac_' + inventory_hostname.split('.')[1]) }} up"
# flush routes and renew lease # flush routes and renew lease
run "/sbin/route -qn flush" run "/sbin/route -qn flush"
run "/usr/sbin/dhcpleasectl vio1" run "/usr/sbin/dhcpleasectl vio1"
@ -31,13 +31,17 @@ state master {
state backup { state backup {
init { init {
# bring down interface and reset mac # bring down interface and reset mac
run "/sbin/ifconfig vio1 delete lladdr {{ gw_home_mac }} down" run "/sbin/ifconfig vio1 delete lladdr {{ lookup('vars', 'gw_mac_' + inventory_hostname.split('.')[1]) }} down"
# flush routes and fix default route # flush routes and fix default route
run "/sbin/route -qn flush" run "/sbin/route -qn flush"
{% if inventory_hostname == "dna-gw01.home.foo.sh" %} {% if inventory_hostname == "dna-gw01.home.foo.sh" %}
run "/sbin/route -qn add default 172.20.21.2" run "/sbin/route -qn add default 172.20.21.2"
{% elif inventory_hostname == "dna-gw02.home.foo.sh" %} {% elif inventory_hostname == "dna-gw02.home.foo.sh" %}
run "/sbin/route -qn add default 172.20.21.1" run "/sbin/route -qn add default 172.20.21.1"
{% elif inventory_hostname == "dna-gw03.home.lan.foo.sh" %}
run "/sbin/route -qn add default 172.20.30.3"
{% elif inventory_hostname == "dna-gw04.home.lan.foo.sh" %}
run "/sbin/route -qn add default 172.20.30.2"
{% endif %} {% endif %}
} }
if $if_carp_up { if $if_carp_up {