r/keepalived: Deploy keepalived

[keepalived][0] is a free implementation of the Virtual Router
Redundancy Protocol (VRRP), which is a simple method for automatically
assigning an IP address to one of several potential hosts based on
certain criteria.  It is particularly useful in conjunction with a load
balancer like HAProxy, to provide layer 3 redundancy in addition to
layer 7.  We will use it for both the reverse proxy for the public
websites and the Kubernetes API server.

[0]: https://www.keepalived.org/
unifi-restore
Dustin 2025-07-22 08:58:17 -05:00
parent 0e6cc4882d
commit f62b11bb9d
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,4 @@
- name: reload keepalived
service:
name: keepalived
state: reloaded

View File

@ -0,0 +1,34 @@
- name: ensure keepalived is installed
package:
name: keepalived
state: present
tags:
- install
- name: ensure keepalived is configured
template:
src: keepalived.conf.j2
dest: /etc/keepalived/keepalived.conf
owner: root
group: root
mode: u=rw,go=r
notify: reload keepalived
tags:
- config
- name: flush handlers
meta: flush_handlers
- name: ensure keepalived starts at boot
service:
name: keepalived
enabled: true
tags:
- service
- name: ensure keepalived is running
service:
name: keepalived
state: started
tags:
- service

View File

@ -0,0 +1,24 @@
{#- vim: set sw=3 sts=3 ts=3 et : -#}
! Configuration File for keepalived
{% if keepalived_global_defs|d %}
global_defs {
{{ keepalived_global_defs | indent(width=3, first=true) }}
}
{% endif %}
{% if vrrp_track_process|d %}
{% for name, config in vrrp_track_process | items %}
vrrp_track_process {{ name }} {
{{ config | indent(width=4, first=true) }}
}
{% endfor %}
{% endif %}
{% if vrrp_instance|d %}
{% for name, config in vrrp_instance | items %}
vrrp_instance {{ name }} {
{{ config | indent(width=4, first=true) }}
}
{% endfor %}
{% endif %}