HAProxy community

HAProxy with keepalived on AWS

Hi!
i am currently using HAProxy 2.0 on two different servers on AWS i am try to configure High Availability with keepalived everything is working expect my notify script. if i can execute script manually it’s working fine but didn’t run automatically when HAProxy-A goes down

here is my current configurations

global_defs {
enable_script_security
script_user ubuntu
}
vrrp_script chk_haproxy {
script “/usr/bin/pkill -0 haproxy”
weight 2
interval 2
fall 3
rise 3
}
vrrp_instance VI_1 {
debug 2
interface eth0 # interface to monitor
state MASTER
virtual_router_id 51 # Assign one ID for this route
priority 101 # 101 on master, 100 on backup
unicast_src_ip 172.31.4.66 # My IP
unicast_peer {
172.31.4.5 # peer IP
}

authentication {
    auth_type PASS
    auth_pass AaP51Mdi
}


track_script {
    chk_haproxy
}
notify_master /usr/local/bin/failover.sh

}

global_defs {
enable_script_security
script_user ubuntu
}
vrrp_script chk_haproxy {
script “/usr/bin/pkill -0 haproxy”
weight 2
interval 2
fall 3
rise 3
}
vrrp_instance VI_1 {
debug 2
interface eth0 # interface to monitor
state BACKUP
virtual_router_id 51 # Assign one ID for this route
priority 100 # 101 on master, 100 on backup
unicast_src_ip 172.31.4.5 # My IP
unicast_peer {
172.31.4.66 # peer IP
}

authentication {
    auth_type PASS
    auth_pass AaP51Mdi
}

track_script {
    chk_haproxy
}
notify_master /usr/local/bin/failover.sh

}

Notify Script

#!/bin/bash

EIP=13.xx.xx.xx
INSTANCE_ID=i-0b06

/usr/bin/aws ec2 disassociate-address --public-ip $EIP
/usr/bin/aws ec2 associate-address --public-ip $EIP --instance-id $INSTANCE_ID