Configured haproxies
This commit is contained in:
40
roles/keepalived/templates/keepalived.conf.j2
Normal file
40
roles/keepalived/templates/keepalived.conf.j2
Normal file
@@ -0,0 +1,40 @@
|
||||
global_defs {
|
||||
router_id HOME-PROXY.WIMER.HOME
|
||||
}
|
||||
|
||||
vrrp_script check_vip {
|
||||
script "curl http://localhost:2016/haproxy"
|
||||
interval 2
|
||||
weight -100
|
||||
}
|
||||
|
||||
vrrp_instance HAPROXY_API_FRONT {
|
||||
{% if play_hosts|first == inventory_hostname %}
|
||||
state MASTER
|
||||
priority 150
|
||||
{% else %}
|
||||
state BACKUP
|
||||
priority 100
|
||||
{% endif %}
|
||||
interface {{ vip_interface }}
|
||||
virtual_router_id {{ vip_address.split('.')[3] }}
|
||||
advert_int 1
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass home
|
||||
}
|
||||
|
||||
dont_track_primary
|
||||
|
||||
track_script {
|
||||
check_vip
|
||||
}
|
||||
|
||||
virtual_ipaddress {
|
||||
{{ vip_address }} dev {{ vip_interface }}
|
||||
}
|
||||
|
||||
notify /usr/local/bin/keepalived_haproxy
|
||||
smtp_alert
|
||||
}
|
||||
20
roles/keepalived/templates/keepalived_haproxy.j2
Normal file
20
roles/keepalived/templates/keepalived_haproxy.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
TYPE=${1}
|
||||
NAME=${2}
|
||||
STATE=${3}
|
||||
|
||||
case ${STATE} in
|
||||
"MASTER") service haproxy start
|
||||
exit 0
|
||||
;;
|
||||
"BACKUP") service haproxy start
|
||||
exit 0
|
||||
;;
|
||||
"FAULT") service haproxy stop
|
||||
exit 0
|
||||
;;
|
||||
*) echo "unknown state"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user