2024-05-16 14:59:12 +00:00
|
|
|
Idempotent ansible role for Keepalived service
|
2023-02-07 22:42:20 +00:00
|
|
|
|
2024-05-16 09:40:52 +00:00
|
|
|
# Config examples
|
|
|
|
<details>
|
|
|
|
<summary>Using template config</summary>
|
2023-02-07 22:42:20 +00:00
|
|
|
|
|
|
|
keepalived_config:
|
|
|
|
global_defs:
|
|
|
|
router_id: t1-dev-rabbitmq
|
|
|
|
vrrp_track_process:
|
|
|
|
haproxy:
|
|
|
|
process: haproxy
|
|
|
|
quorum: 1
|
|
|
|
delay: 2
|
|
|
|
vrrp_instance:
|
|
|
|
VRRP_1:
|
|
|
|
state: MASTER
|
|
|
|
virtual_router_id: 50
|
|
|
|
priority: "{{ ansible_default_ipv4.address.split('.')[-1][-2:] }}"
|
|
|
|
interface: "{{ ansible_default_ipv4.interface }}"
|
|
|
|
unicast_src_ip: "{{ ansible_default_ipv4.address }}"
|
|
|
|
unicast_peer:
|
|
|
|
- 10.89.10.71
|
|
|
|
- 10.89.10.72
|
|
|
|
- 10.89.10.73
|
|
|
|
virtual_ipaddress:
|
|
|
|
- "10.89.10.112/32 dev {{ ansible_default_ipv4.interface }}"
|
|
|
|
track_process:
|
|
|
|
- haproxy
|
|
|
|
|
2024-05-16 09:40:52 +00:00
|
|
|
</details>
|
|
|
|
|
|
|
|
<details>
|
|
|
|
<summary>Complete config override</summary>
|
|
|
|
|
|
|
|
keepalived_config_override: |
|
|
|
|
global_defs {
|
|
|
|
router_id {{ patroni_cluster_name | default('default') }}
|
|
|
|
}
|
|
|
|
vrrp_track_process haproxy {
|
|
|
|
process haproxy
|
|
|
|
quorum 1
|
|
|
|
delay 2
|
|
|
|
}
|
|
|
|
vrrp_instance VRRP_1 {
|
|
|
|
state MASTER
|
|
|
|
virtual_router_id {{ keepalived_vip.split('.')[-1][-3:] }}
|
|
|
|
priority {{ ansible_enp3s0.ipv4.address.split('.')[-1][-3:] | default(ansible_default_ipv4.address.split('.')[-1][-3:]) }}
|
|
|
|
interface {{ ansible_enp3s0.device | default(ansible_default_ipv4.interface) }}
|
|
|
|
unicast_src_ip {{ ansible_enp3s0.ipv4.address | default(ansible_default_ipv4.address) }}
|
|
|
|
unicast_peer {
|
|
|
|
{% for peer in groups.all %}
|
|
|
|
{{ hostvars[peer].ansible_enp3s0.ipv4.address if hostvars[peer].ansible_enp3s0.ipv4.address != ansible_enp3s0.ipv4.address }}
|
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
virtual_ipaddress {
|
|
|
|
{{ keepalived_vip }}/32 dev enp3s0
|
|
|
|
}
|
|
|
|
track_process {
|
|
|
|
haproxy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</details>
|