Hi all,
VyOS Version: 1.3-beta-202112050443
My VRRP master script doesn’t always get executed when switching to master.
I have two groups eth0 (WAN) and eth1 (LAN). VRRP failover works fine. I have created a sync-group called MAIN where I have placed the transition-script line. I have tested that it does work if I execute independently.
It also works if I attach the master script to the sync for just eth0, and then after reboot/process restart it stops working.
The show log vrrp - is not showing any errors. My script also has an output that shows up in the log when it has worked.
Same configuration below on both routers, different priorities (100, 200)
high-availability {
vrrp {
group eth0 {
interface eth0
no-preempt
priority 100
rfc3768-compatibility
virtual-address <floating IP>
vrid 10
}
group eth1 {
interface eth1
no-preempt
priority 100
rfc3768-compatibility
virtual-address <Internal VIP IP>
vrid 11
}
sync-group MAIN {
member eth0
member eth1
transition-script {
master /config/scripts/<my script name>.sh
}
}
}
}
My script
#!/usr/bin/bash
RESERVED_IP_INSTANCE_ID='sanitized'
API_KEY='sanitized'
VM_INSTANCE_ID='sanitized'
#determine if the floating ip has been assigned
HAS_FLOATING_IP=`curl -s https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID} -X GET -H "Authorization: Bearer ${API_KEY}"`
#debug
logger -s ${HAS_FLOATING_IP}
#check to see if this instance has the floating ip
if [[ "${HAS_FLOATING_IP}" != *"${VM_INSTANCE_ID}"* ]]; then
logger -s "This machine does not have a IP assigned to this machine already. Let's assign it."
#detach
`curl -s "https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID}/detach" \
-X POST \
-H "Authorization: Bearer ${API_KEY}"`
#attach
`curl -s "https://api.vultr.com/v2/reserved-ips/${RESERVED_IP_INSTANCE_ID}/attach" \
-X POST \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"instance_id\" : \"${VM_INSTANCE_ID}\"}"`
fi
logger -s "Completed IP failover"
exit