Keepalived notify script isn't executed

9,534

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:

[root@server ~]# journalctl

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

      notify_master "/path/to/script"
      notify_backup "/path/to/script"

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:

   ausearch -c 'keepalived' --raw | audit2allow -M my-keepalived

   semodule -i my-keepalived.pp

Once you run these commands, restart keepalived:

   service keepalived restart
Share:
9,534
Peco
Author by

Peco

Updated on September 18, 2022

Comments

  • Peco
    Peco almost 2 years

    I just set up the notification script in /etc/keepalived/keepalived.conf

    /etc/keepalived/keepalived.conf

    global_defs {
      notification_email {
        [email protected]
      }
      notification_email_from [email protected]
      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

    enter image description here

    It seems working but those shellscripts are not executed.

    Do you have any suggestion?

    • svrist
      svrist over 8 years
      I've actually seen the same. I moved the lines to another location in the instance definition and then they worked....