add notify script
This commit is contained in:
parent
a7a68de0df
commit
84c261f102
|
@ -1,4 +1,12 @@
|
||||||
vrrp_instance vip-1 {
|
vrrp_sync_group VG_1 {
|
||||||
|
group {
|
||||||
|
VI_1
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ keepalived_notify }}
|
||||||
|
}
|
||||||
|
|
||||||
|
vrrp_instance VI_1 {
|
||||||
interface {{ keepalived_interface }}
|
interface {{ keepalived_interface }}
|
||||||
|
|
||||||
track_interface {
|
track_interface {
|
||||||
|
@ -22,6 +30,4 @@ vrrp_instance vip-1 {
|
||||||
auth_type PASS
|
auth_type PASS
|
||||||
auth_pass {{ keepalived_password }}
|
auth_pass {{ keepalived_password }}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ keepalived_notify }}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# for ANY state transition.
|
||||||
|
# "notify" script is called AFTER the
|
||||||
|
# notify_* script(s) and is executed
|
||||||
|
# with 3 arguments provided by keepalived
|
||||||
|
# (ie don't include parameters in the notify line).
|
||||||
|
# arguments
|
||||||
|
# $1 = "GROUP"|"INSTANCE"
|
||||||
|
# $2 = name of group or instance
|
||||||
|
# $3 = target state of transition
|
||||||
|
# ("MASTER"|"BACKUP"|"FAULT")
|
||||||
|
|
||||||
TYPE=$1
|
TYPE=$1
|
||||||
NAME=$2
|
NAME=$2
|
||||||
STATE=$3
|
STATE=$3
|
||||||
|
|
||||||
case $STATE in
|
case $STATE in
|
||||||
"MASTER") echo "I'm the MASTER! Whup whup."
|
"MASTER") echo "I'm the MASTER! Whup whup." >> keepalived.info
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"BACKUP") "Ok, i'm just a backup, great."
|
"BACKUP") "Ok, i'm just a backup, great." >> keepalived.info
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"FAULT") echo "Fault, what ?"
|
"FAULT") echo "Fault, what ?" >> keepalived.info
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*) echo "Unknown state"
|
*) echo "Unknown state" >> keepalived.info
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -23,7 +23,8 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
||||||
sed -i "s|{{ keepalived_password }}|$KEEPALIVED_PASSWORD|g" /etc/keepalived/keepalived.conf
|
sed -i "s|{{ keepalived_password }}|$KEEPALIVED_PASSWORD|g" /etc/keepalived/keepalived.conf
|
||||||
|
|
||||||
if [ -n "$KEEPALIVED_NOTIFY" ]; then
|
if [ -n "$KEEPALIVED_NOTIFY" ]; then
|
||||||
sed -i "s|{{ keepalived_notify }}|notify $KEEPALIVED_NOTIFY|g" /etc/keepalived/keepalived.conf
|
sed -i "s|{{ keepalived_notify }}|notify \"$KEEPALIVED_NOTIFY\"|g" /etc/keepalived/keepalived.conf
|
||||||
|
chmod 777 $KEEPALIVED_NOTIFY
|
||||||
else
|
else
|
||||||
sed -i "/{{ keepalived_notify }}/d" /etc/keepalived/keepalived.conf
|
sed -i "/{{ keepalived_notify }}/d" /etc/keepalived/keepalived.conf
|
||||||
fi
|
fi
|
||||||
|
@ -60,7 +61,7 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat /etc/keepalived/keepalived.conf
|
cat /etc/keepalived/keepalived.conf
|
||||||
cat /osixia/keepalived/notify-example.sh
|
cat $KEEPALIVED_NOTIFY
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue