I just set up the notification script in /etc/keepalived/keepalived.conf
/etc/keepalived/keepalived.conf
global_defs {
notification_email {
admin@example.com
}
notification_email_from keepalived@example.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id DEFAULT_ROUT_ID
}
vrrp_script notification {
script ""
interval
weight
}
vrrp_instance VI_1 {
interface eth0
virtual_router_id 10
nopreempt
state backup
priority 110
advert_int 1
virtual_ipaddress {
22.22.22.22
}
track_script {
notification
}
notify_master "/etc/keepalived/master.sh"
notify_backup "/etc/keepalived/backup.sh"
}
And Whenever the state changes, it comes out
It seems working but those shellscripts are not executed.
Do you have any suggestion?
Best Answer
I had this same issue too, my notify script wasn't being executed, at the end of the day, I realized SELinux was blocking my script from being run, I found this out by typing:
so go through the output, it will give you a hint as to the command to disable SELinux so your notify script can run. Also, I didn't use notify but
Result from SELinux: If you believe that keepalived should have the dac_override capability by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing these commands:
Once you run these commands, restart keepalived: