summaryrefslogtreecommitdiffstats
path: root/roles/keepalived/templates
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2017-04-01 04:53:28 +0200
committerSuren A. Chilingaryan <csa@suren.me>2017-04-01 04:53:28 +0200
commite7ed329bd81c2273c03e94c93c9ce9c1d01cdc86 (patch)
tree444778102e4f73b83ef9462235b7f614b004b264 /roles/keepalived/templates
downloadands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.gz
ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.bz2
ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.xz
ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.zip
Initial import
Diffstat (limited to 'roles/keepalived/templates')
-rw-r--r--roles/keepalived/templates/keepalived.conf.j236
1 files changed, 36 insertions, 0 deletions
diff --git a/roles/keepalived/templates/keepalived.conf.j2 b/roles/keepalived/templates/keepalived.conf.j2
new file mode 100644
index 0000000..8d9a580
--- /dev/null
+++ b/roles/keepalived/templates/keepalived.conf.j2
@@ -0,0 +1,36 @@
+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 %}