92 lines
2.3 KiB
Django/Jinja
92 lines
2.3 KiB
Django/Jinja
{{ ansible_managed | comment }}
|
|
|
|
global_defs {
|
|
dynamic_interfaces
|
|
script_user root
|
|
enable_script_security
|
|
vrrp_version 3
|
|
{% if keepalived__max_auto_priority is defined %}
|
|
max_auto_priority {{ keepalived__max_auto_priority | int }}
|
|
{% endif %}
|
|
}
|
|
|
|
{%
|
|
set ipv4_enabled =
|
|
keepalived__ipv4_enabled
|
|
| default(keepalived__virtual_addresses.values()
|
|
| flatten | ansible.utils.ipv4)
|
|
%}
|
|
{%
|
|
set ipv6_enabled =
|
|
keepalived__ipv6_enabled
|
|
| default(keepalived__virtual_addresses.values()
|
|
| flatten | ansible.utils.ipv6)
|
|
%}
|
|
|
|
{% if ipv4_enabled and ipv6_enabled %}
|
|
vrrp_sync_group group {
|
|
group {
|
|
{% if ipv4_enabled %}
|
|
instance_v4
|
|
{% endif %}
|
|
{% if ipv6_enabled %}
|
|
instance_v6
|
|
{% endif %}
|
|
}
|
|
notify_master "/etc/keepalived/notify.sh master"
|
|
notify_backup "/etc/keepalived/notify.sh backup"
|
|
notify_fault "/etc/keepalived/notify.sh fault"
|
|
}
|
|
{% endif %}
|
|
|
|
{% if ipv4_enabled %}
|
|
vrrp_instance instance_v4 {
|
|
virtual_router_id {{ keepalived__virtual_router_id | int }}
|
|
interface {{ keepalived__interface }}
|
|
state BACKUP
|
|
priority 250
|
|
nopreempt
|
|
advert_int 1
|
|
accept
|
|
virtual_ipaddress {
|
|
{% for dev, addresses in keepalived__virtual_addresses.items() %}
|
|
{% for address in addresses %}
|
|
{% if address | ansible.utils.ipv4 %}
|
|
{{ address }} dev {{ dev }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
}
|
|
{% if not (ipv4_enabled and ipv6_enabled) %}
|
|
notify_master "/etc/keepalived/notify.sh master"
|
|
notify_backup "/etc/keepalived/notify.sh backup"
|
|
notify_fault "/etc/keepalived/notify.sh fault"
|
|
{% endif %}
|
|
}
|
|
{% endif %}
|
|
|
|
{% if ipv6_enabled %}
|
|
vrrp_instance instance_v6 {
|
|
virtual_router_id {{ keepalived__virtual_router_id | int }}
|
|
interface {{ keepalived__interface }}
|
|
state BACKUP
|
|
priority 250
|
|
nopreempt
|
|
advert_int 1
|
|
accept
|
|
virtual_ipaddress {
|
|
{% for dev, addresses in keepalived__virtual_addresses.items() %}
|
|
{% for address in addresses | ipaddr_sort(["link-local"]) %}
|
|
{% if address | ansible.utils.ipv6 %}
|
|
{{ address }} dev {{ dev }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
}
|
|
{% if not (ipv4_enabled and ipv6_enabled) %}
|
|
notify_master "/etc/keepalived/notify.sh master"
|
|
notify_backup "/etc/keepalived/notify.sh backup"
|
|
notify_fault "/etc/keepalived/notify.sh fault"
|
|
{% endif %}
|
|
}
|
|
{% endif %}
|