2020-08-14 14:08:11 +00:00
|
|
|
global_defs {
|
|
|
|
{% if keepalived_mail|default(False) %}
|
|
|
|
notification_email {
|
|
|
|
{{ keepalived_mail.mail_to }}
|
|
|
|
}
|
|
|
|
notification_email_from {{ keepalived_mail.mail_from }}
|
|
|
|
smtp_server {{ keepalived_mail.smtp_server|default('localhost') }}
|
|
|
|
smtp_connect_timeout {{ keepalived_mail.smtp_timeout|default(10) }}
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
script_user root
|
|
|
|
enable_script_security
|
|
|
|
}
|
|
|
|
|
|
|
|
{% if keepalived_chk_proc_name|default(False) %}
|
|
|
|
# Fast, but does not work in container
|
|
|
|
vrrp_track_process track_{{ keepalived_chk_proc_name }} {
|
|
|
|
process {{ keepalived_chk_proc_name }}
|
|
|
|
quorum 1
|
|
|
|
delay 2
|
|
|
|
weight 10
|
|
|
|
}
|
|
|
|
|
|
|
|
# Slow, but should always work
|
|
|
|
vrrp_script chk_{{ keepalived_chk_proc_name }} {
|
|
|
|
script "/bin/pidof {{ keepalived_chk_proc_name }}"
|
|
|
|
interval {{ keepalived_chk_proc_interval|default(2) }}
|
|
|
|
weight 10
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
vrrp_instance {{ keepalived_instance_name|default('VI_1') }} {
|
|
|
|
state {{ keepalived_state|default('BACKUP') }}
|
|
|
|
interface {{ keepalived_interface|default('eth0') }}
|
2020-12-01 21:14:26 +00:00
|
|
|
virtual_router_id {{ keepalived_router_id|default((keepalived_virtual_ipaddress|ipaddr('address')).0.split('.')[3]) }}
|
2020-08-14 14:08:11 +00:00
|
|
|
priority {{ ((keepalived_state|default('BACKUP'))=='MASTER')|ternary('100', '95') }}
|
|
|
|
advert_int {{ keepalived_advert_int|default(1) }}
|
|
|
|
authentication {
|
|
|
|
auth_type PASS
|
2021-12-08 19:32:16 +00:00
|
|
|
auth_pass {{ keepalived_auth_pass|default(lookup('password', './.keepalived.pw length=8')) }}
|
2020-08-14 14:08:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual_ipaddress {
|
|
|
|
{% for keepalived_ip in keepalived_virtual_ipaddress %}{{ keepalived_ip }}
|
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
|
|
|
|
{% if keepalived_chk_proc_name|default(False) %}
|
|
|
|
# track_process track_{{ keepalived_chk_proc_name }} {
|
|
|
|
# {{ keepalived_chk_proc_name }}
|
|
|
|
# }
|
|
|
|
|
|
|
|
track_script {
|
|
|
|
chk_{{ keepalived_chk_proc_name }}
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
|
|
|
|
! https://www.linux-magazin.de/ausgaben/2015/07/einfuehrung2/
|
|
|
|
! https://www.digitalocean.com/community/tutorials/how-to-set-up-highly-available-web-servers-with-keepalived-and-floating-ips-on-ubuntu-14-04
|
|
|
|
|