Configured haproxies

This commit is contained in:
2019-04-08 10:53:13 -04:00
parent a5e3dbd8ba
commit 98810165e0
9 changed files with 204 additions and 14 deletions

View 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
}

View 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