-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathkeepalived.conf.j2
45 lines (38 loc) · 996 Bytes
/
keepalived.conf.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{% if globals|length %}
global_defs {
{% if globals['vrrp_garp_master_refresh'] is defined %}vrrp_garp_master_refresh {{ globals['vrrp_garp_master_refresh'] }}{% endif %}
}
{% endif %}
{%- for item in vrrp_ips %}
vrrp_script script_{{ item['id'] }} {
script "/usr/local/bin/check_haproxy.sh"
interval 2
fall 2
rise 2
}
vrrp_instance balancer_{{ item['id'] }} {
state BACKUP
interface {{ item['interface'] }}
virtual_router_id {{ item['router_id'] }}
priority {{ item['priority'] }}
nopreempt
virtual_ipaddress {
{{ item['ip'] }} dev {{ item['interface'] }} label vip_{{ item['id'] }}
}
track_script {
script_{{ item['id'] }}
}
authentication {
auth_type PASS
auth_pass {{ item['password'] }}
}
{%- if item['peers'] | length > 0 %}
unicast_src_ip {{ item['source'] }}
unicast_peer {
{%- for ip in item['peers'] %}
{{ ip }}
{%- endfor %}
}
{%- endif %}
}
{%- endfor %}