global_defs { } vrrp_script track { script "[ -f /etc/keepalived/track.sh ] || exit 0 && /etc/keepalived/track.sh" interval {{ keepalived_check_interval }} } {% for vips in keepalived_vips %} {% set id = ( vips | ipaddr('address') | regex_replace('^.*\.', '') ) %} vrrp_instance VI_{{ loop.index }} { virtual_router_id {{ id }} state {{ (( ( loop.index - 1) % (keepalived_num_nodes | int) ) == (keepalived_node_id | int) ) | ternary('MASTER', 'BACKUP') }} state {{ (( ( loop.index - 1) % (keepalived_num_nodes | int) ) == (keepalived_node_id | int) ) | ternary(keepalived_master_prio, keepalived_backup_prio) }} interface {{ keepalived_iface }} virtual_ipaddress { {{ vips }} dev {{ keepalived_iface }} } advert_int 1 authentication { auth_type PASS auth_pass {{ keepalived_password }} } track_script { track } } {% endfor %}