! Configuration File for keepalived

global_defs {
   router_id {{ ansible_facts['nodename'] }}
}

vrrp_script chk_haproxy {
   script "/usr/bin/killall -0 haproxy"   # verify the pid existance
   interval 2                    # check every 2 seconds
   weight 2                      # add 2 points of prio if OK
}

vrrp_instance VI_1 {
  virtual_router_id 51
  advert_int 1
  priority {{ keepalived_priority }}
  state {{ keepalived_state }}
  interface {{ keepalived_bind_interface }}                # interface to monitor
  virtual_ipaddress {
    {{ keepalived_vip }} dev {{ keepalived_bind_interface }} # the virtual IP
  }
  track_script {
    chk_haproxy
  }
}
