global_defs { script_user nobody enable_script_security } vrrp_script chk_avail { script "{{ keepalived_healthcheck_script }}" interval 1 weight 10 rise 6 fall 1 } vrrp_instance {{ inventory_hostname }} { interface {{ keepalived_interface }} state BACKUP virtual_router_id {{ keepalived_virtual_router_id }} priority {{ keepalived_priority }} advert_int 1 unicast_src_ip {{ ansible_host }} unicast_peer { {% for peer in groups['keepalived'] if hostvars[peer]['ansible_host'] != ansible_host %} {{ hostvars[peer]['ansible_host'] }} {% endfor %} } virtual_ipaddress { {{ keepalived_virtual_ip }} dev {{ keepalived_interface }} } track_script { chk_avail } }