WIP: Infrastructure routers #91
3 changed files with 85 additions and 0 deletions
6
roles/keepalived/handlers/main.yml
Normal file
6
roles/keepalived/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Reload keepalived
|
||||||
|
systemd:
|
||||||
|
name: keepalived.service
|
||||||
|
state: reloaded
|
||||||
|
...
|
21
roles/keepalived/tasks/main.yml
Normal file
21
roles/keepalived/tasks/main.yml
Normal 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
|
||||||
|
...
|
58
roles/keepalived/templates/keepalived.conf
Normal file
58
roles/keepalived/templates/keepalived.conf
Normal 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 %}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue