Add keepalived role
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
jeltz 2022-01-01 21:45:17 +01:00
parent 0d705bc922
commit a616065513
3 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,6 @@
---
- name: Reload keepalived
systemd:
name: keepalived.service
state: reloaded
...

View file

@ -0,0 +1,21 @@
---
- name: Install keepalived
apt:
name: keepalived
- name: Configure keepalived
template:
src: keepalived.conf
dest: /etc/keepalived/keepalived.conf
owner: root
group: root
mode: u=rw,g=,o=
notify:
- Reload keepalived
- name: Enable and start keepalived
systemd:
name: keepalived
enabled: true
state: started
...

View file

@ -0,0 +1,58 @@
{{ ansible_managed | comment }}
global_defs {
dynamic_interfaces
script_user root
enable_script_security
vrrp_version 3
}
vrrp_sync_group group {
group {
instance_v4
instance_v6
}
{% if keepalived_notify_master %}
notify_master "{{ keepalived_notify_master }}"
{% endif %}
{% if keepalived_notify_backup is defined %}
notify_backup "{{ keepalived_notify_backup }}"
{% endif %}
{% if keepalived_notify_fault is defined %}
notify_fault "{{ keepalived_notify_fault }}"
{% endif %}
}
vrrp_instance instance_v4 {
virtual_router_id {{ keepalived_virtual_router_id }}
interface {{ keepalived_interface }}
state BACKUP
priority 250
nopreempt
advert_int 1
accept
virtual_ipaddress {
{% for dev, addrs in keepalived_virtual_addresses_v4.items() %}
{% for addr in addrs %}
{{ addr }} dev {{ dev }}
{% endfor %}
{% endfor %}
}
}
vrrp_instance instance_v6 {
virtual_router_id {{ keepalived_virtual_router_id }}
interface {{ keepalived_interface }}
state BACKUP
priority 250
nopreempt
advert_int 1
accept
virtual_ipaddress {
{% for dev, addrs in keepalived_virtual_addresses_v6.items() %}
{% for addr in addrs %}
{{ addr }} dev {{ dev }}
{% endfor %}
{% endfor %}
}
}