add notify script
This commit is contained in:
parent
64183ccd88
commit
a7a68de0df
|
@ -1,4 +1,7 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
- Add notify script
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|
|
@ -10,3 +10,5 @@ KEEPALIVED_UNICAST_PEERS:
|
||||||
|
|
||||||
KEEPALIVED_VIRTUAL_IPS:
|
KEEPALIVED_VIRTUAL_IPS:
|
||||||
- 192.168.1.231
|
- 192.168.1.231
|
||||||
|
|
||||||
|
KEEPALIVED_NOTIFY: /osixia/keepalived/notify-example.sh
|
||||||
|
|
|
@ -22,4 +22,6 @@ vrrp_instance vip-1 {
|
||||||
auth_type PASS
|
auth_type PASS
|
||||||
auth_pass {{ keepalived_password }}
|
auth_pass {{ keepalived_password }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{ keepalived_notify }}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TYPE=$1
|
||||||
|
NAME=$2
|
||||||
|
STATE=$3
|
||||||
|
|
||||||
|
case $STATE in
|
||||||
|
"MASTER") echo "I'm the MASTER! Whup whup."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"BACKUP") "Ok, i'm just a backup, great."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"FAULT") echo "Fault, what ?"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*) echo "Unknown state"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
|
@ -22,6 +22,12 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
||||||
sed -i "s|{{ keepalived_priority }}|$KEEPALIVED_PRIORITY|g" /etc/keepalived/keepalived.conf
|
sed -i "s|{{ keepalived_priority }}|$KEEPALIVED_PRIORITY|g" /etc/keepalived/keepalived.conf
|
||||||
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
|
||||||
|
sed -i "s|{{ keepalived_notify }}|notify $KEEPALIVED_NOTIFY|g" /etc/keepalived/keepalived.conf
|
||||||
|
else
|
||||||
|
sed -i "/{{ keepalived_notify }}/d" /etc/keepalived/keepalived.conf
|
||||||
|
fi
|
||||||
|
|
||||||
# unicast peers
|
# unicast peers
|
||||||
KEEPALIVED_UNICAST_PEERS=($KEEPALIVED_UNICAST_PEERS)
|
KEEPALIVED_UNICAST_PEERS=($KEEPALIVED_UNICAST_PEERS)
|
||||||
for peer in "${KEEPALIVED_UNICAST_PEERS[@]}"
|
for peer in "${KEEPALIVED_UNICAST_PEERS[@]}"
|
||||||
|
@ -53,6 +59,9 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
||||||
sed -i "/{{ keepalived_virtual_ips }}/d" /etc/keepalived/keepalived.conf
|
sed -i "/{{ keepalived_virtual_ips }}/d" /etc/keepalived/keepalived.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat /etc/keepalived/keepalived.conf
|
||||||
|
cat /osixia/keepalived/notify-example.sh
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch $FIRST_START_DONE
|
touch $FIRST_START_DONE
|
||||||
|
|
Loading…
Reference in New Issue