59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
# FIXME: NOTICE: setting config option max_auto_priority should result in better keepalived performance
|
|
|
|
global_defs {
|
|
enable_script_security
|
|
script_user "{{ keepalived_script_user }}"
|
|
{% if keepalived_alerts_to | length > 0 %}
|
|
|
|
notification_email {
|
|
{% for dest in keepalived_alerts_to %}
|
|
{{ dest }}
|
|
{% endfor %}
|
|
}
|
|
notification_email_from {{ keepalived_smtp_from }}
|
|
smtp_server {{ keepalived_smtp_relay }}
|
|
smtp_connect_timeout 30
|
|
router_id {{ ansible_hostname }}
|
|
{% endif %}
|
|
}
|
|
|
|
vrrp_script chk_{{ keepalived_monitored_process }} {
|
|
script "/usr/bin/killall -0 {{ keepalived_monitored_process }}" # Check if process is running
|
|
interval 2 # Check every 2 seconds
|
|
weight 2 # Weight to influence master election
|
|
}
|
|
{% for ip in keepalived_vrrp_ips %}
|
|
|
|
# master: {{ ip.master }}
|
|
vrrp_instance VI_{{ ip.virtual_router_id }} {
|
|
state {{ (ansible_hostname==ip.master) | ternary('MASTER', 'BACKUP') }}
|
|
interface {{ ansible_default_ipv4.interface }}
|
|
virtual_router_id {{ ip.virtual_router_id }}
|
|
priority {{ (ansible_hostname==ip.master) | ternary('101', '100') }}
|
|
advert_int 1
|
|
promote_secondaries
|
|
{% if keepalived_alerts_to | length > 0 %}
|
|
smtp_alert true
|
|
{% endif %}
|
|
authentication {
|
|
auth_type PASS
|
|
auth_pass {{ keepalived_vrrp_password }}
|
|
}
|
|
virtual_ipaddress {
|
|
{{ ip.addr }}
|
|
}
|
|
{% if keepalived_unicast_peers | length > 0 %}
|
|
unicast_peer {
|
|
{% for peer in keepalived_unicast_peers %}
|
|
{% if peer != ansible_default_ipv4.address %}
|
|
{{ peer }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
}
|
|
{% endif %}
|
|
track_script {
|
|
chk_{{ keepalived_monitored_process }}
|
|
}
|
|
}
|
|
{% endfor %}
|