summaryrefslogtreecommitdiffstats
path: root/roles/keepalived/templates/keepalived.conf.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/keepalived/templates/keepalived.conf.j2')
-rw-r--r--roles/keepalived/templates/keepalived.conf.j215
1 files changed, 9 insertions, 6 deletions
diff --git a/roles/keepalived/templates/keepalived.conf.j2 b/roles/keepalived/templates/keepalived.conf.j2
index 8d9a580..6df5eab 100644
--- a/roles/keepalived/templates/keepalived.conf.j2
+++ b/roles/keepalived/templates/keepalived.conf.j2
@@ -6,20 +6,22 @@ vrrp_script track {
interval {{ keepalived_check_interval }}
}
-{% for vips in keepalived_vips %}
-{% set id = ( vips | ipaddr('address') | regex_replace('^.*\.', '') ) %}
+{% for vrrp in keepalived_vrrp %}
+{% set vrrp_id = loop.index %}
+{% for vips in vrrp.vips %}
+{% set id = ( vips | ipaddr('address') | regex_replace('^.*\.', '') ) %}
-vrrp_instance VI_{{ loop.index }} {
+vrrp_instance VI_{{vrrp_id}}_{{ loop.index }} {
- virtual_router_id {{ id }}
+ virtual_router_id {{ (vrrp_id - 1) * 32 + (loop.index) }}
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 }}
+ interface {{ vrrp.iface }}
virtual_ipaddress {
- {{ vips }} dev {{ keepalived_iface }}
+ {{ vips }} dev {{ vrrp.iface }}
}
advert_int 1
@@ -33,4 +35,5 @@ vrrp_instance VI_{{ loop.index }} {
track
}
}
+{% endfor %}
{% endfor %}