Notify Keepalived Scripts not running

1.2k views Asked by At

I am trying to run keepalived between two VPN servers. All work fine, unless the notify scripts that are not executed. Keepalived is configured on Ubuntu 20 servers. I need to run the notify scripts to change the Virtual Address location from one server to the other.

The keepalived.conf:

global_defs {
  enable_script_security
  router_id LVS_DEVEL
  vrrp_skip_check_adv_addr
  vrrp_garp_interval 0.001
  vrrp_gna_interval 0.000001
}
 
vrrp_script check_vpnserver {
  script "/etc/keepalived/check_vpnserver.sh"
  interval 3
  weight -2
  fall 10
  rise 2
}

vrrp_instance wireguard-vip {
  state BACKUP
  priority 100
  interface ens3                       # Network card
  virtual_router_id 60
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 1111
  }
  unicast_src_ip xx.xx.xx.211     # The IP address of this machine
  unicast_peer {
    xx.xx.xx.77                           # The IP address of peer machines
  }
   
  virtual_ipaddress {
    xx.xx.xx.92/32                  # The VIP address
  }
   
  track_script {
    check_vpnserver
  }
  notify_master "/etc/keepalived/scripts/keepalived_notify.sh"
  notify_backup "/etc/keepalived/scripts/keepalived_notify.sh"
  notify_fault "/etc/keepalived/scripts/keepalived_notify.sh"
}

check_vpnserver.sh works fine:

#!/bin/sh
errorExit() {
    echo "*** $*" 1>&2
    exit 1
}
if netstat -nlp | grep -q 52345; then
    echo "OK"
    return 0
else
    echo "Error server down"
    return 1
fi

keepalived.sh never runs:

#!/bin/bash

echo "$1 $2 has transitioned to the $3 state with a priority of $4" > /var/run/keepalived_status
echo "testinggg"

ENDSTATE=$3
NAME=$2
TYPE=$1

case $ENDSTATE in
    "BACKUP") echo "backup modeee"# Perform action for transition to BACKUP state
              exit 0
              ;;
    "FAULT")  echo "Fault mode"# Perform action for transition to FAULT state
              exit 0
              ;;
    "MASTER") echo "Master mode"# Perform action for transition to MASTER state
              exit 0
              ;;
    *)        echo "Unknown state ${ENDSTATE} for VRRP ${TYPE} ${NAME}"
              exit 1
              ;;
esac

When the keepalived change states resturns this logs:

Keepalived_vrrp[3238070]: (wireguard-vip) Backup received priority 0 advertisement
Keepalived_vrrp[3238070]: (wireguard-vip) Backup received priority 0 advertisement
Keepalived_vrrp[3238070]: (wireguard-vip) Entering MASTER STATE

I never saw a message as "Opening script file /etc/keepalived/scripts/keepalived_notify.sh"

Searching, i found this post Keepalived notify not running the script, but responds only for centos.

0

There are 0 answers