-
Notifications
You must be signed in to change notification settings - Fork 131
/
keepalived.conf.j2
65 lines (60 loc) · 1.52 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
! Configuration File for keepalived
global_defs {
}
vrrp_script chk_apiserver {
{% if ansible_facts['os_family'] == "RedHat" %}
script "/usr/libexec/keepalived/check_apiserver.sh"
{% else %}
script "/etc/keepalived/check_apiserver.sh"
{% endif %}
interval 2
weight -5
fall 3
rise 2
}
vrrp_script chk_rke2server {
{% if ansible_facts['os_family'] == "RedHat" %}
script "/usr/libexec/keepalived/check_rke2server.sh"
{% else %}
script "/etc/keepalived/check_rke2server.sh"
{% endif %}
interval 2
weight -5
fall 3
rise 2
}
vrrp_instance VI_1 {
interface {{ ansible_default_ipv4.interface }}
virtual_router_id 11
{% if groups[rke2_servers_group_name].0 == inventory_hostname|string() %}
state MASTER
{% else %}
state BACKUP
{% endif %}
{% for host in groups[rke2_servers_group_name] %}
{%- if host|string() == inventory_hostname|string() %}
priority {{ 150 - loop.index0 }}
{% endif -%}
{% endfor %}
advert_int 1
unicast_src_ip {{ ansible_default_ipv4.address }}
unicast_peer {
{% for host in groups[rke2_servers_group_name] %}
{% if host|string() != inventory_hostname|string() %}
{{ hostvars[host]['ansible_default_ipv4']['address'] }}
{% endif %}
{% endfor %}
}
authentication {
auth_type PASS
auth_pass rke2servers
}
### The following entry is the VRRP config for the incoming interface ###
virtual_ipaddress {
{{ rke2_api_ip }}
}
track_script {
chk_apiserver
chk_rke2server
}
}