{% set vip_cluster_members = hostvars|json_query(vip_cluster_members_query) %}

global_defs {
  router_id {{ node_cluster }}
   enable_script_security
   script_user root
}

vrrp_instance {{ node_cluster }} {

  state {{ vip_role | upper }}

  interface {{ vip_interface }}

  virtual_router_id {{ vip_vrid }}

  {% if vip_role|upper == 'MASTER' %}
  priority 128
  {% else %}
  priority 100
  {% endif %}

{% if vip_preempt|bool %}
  # preempt is enabled by default
{% else %}
  nopreempt
{% endif %}

  advert_int 1
  unicast_src_ip {{ inventory_hostname }}
  unicast_peer {

{% for host in vip_cluster_members %}
{% if host.inventory_hostname != inventory_hostname %}     {{ host.inventory_hostname }}
{% endif %}
{% endfor %}

  }

  authentication {
    auth_type PASS
    auth_pass {% if vip_auth_pass is defined and vip_auth_pass != '' %}{{ vip_auth_pass }}{% else %}{{ node_cluster }}-{{ vip_vrid }}{% endif %}

  }

  virtual_ipaddress {
    {{ vip_address }}
  }

}