role_keepalived/templates/keepalived.j2

87 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

2023-04-12 12:09:46 +00:00
# {{ ansible_managed }}
global_defs {
{% if keepalived_mail_to | length > 0 %}
notification_email {
{{ keepalived_mail_to }}
}
{% endif %}
{% if keepalived_mail_from | length > 0 %}
notification_email_from {{ keepalived_mail_from }}
smtp_server 127.0.0.1
smtp_connect_timeout 30
{% endif %}
2023-09-26 14:40:09 +00:00
script_user keepalived_script
2023-04-12 12:09:46 +00:00
enable_script_security
max_auto_priority 50
}
{% for script in keepalived_track_scripts %}
vrrp_script {{ script.name }} {
script "{{ script.command }}"
2023-04-12 12:09:46 +00:00
interval {{ script.interval }}
}
{% endfor %}
{% for process in keepalived_track_processes %}
vrrp_track_process {{ process.name }} {
process "{{ process.search }}"
quorum {{ process.quorum }}
}
{% endfor %}
vrrp_instance VIP_{{ keepalived_uid }} {
state BACKUP
priority {{ keepalived_priority }}
nopreempt
interface {{ keepalived_interface }}
virtual_router_id {{ keepalived_uid }}
advert_int 1
2023-04-21 12:28:05 +00:00
{% if keepalived_peers | length > 0 %}
2023-09-26 14:40:09 +00:00
unicast_src_ip {{ ansible_facts[keepalived_interface]['ipv4']['address'] }}
2023-04-21 12:28:05 +00:00
unicast_peer {
{% for peer in keepalived_peers %}
{% if peer != ansible_facts[keepalived_interface]['ipv4']['address'] %}
{{ peer }}
{% endif %}
{% endfor %}
}
{% endif %}
2023-04-12 12:09:46 +00:00
{% if keepalived_ipv4 | length > 0 %}
virtual_ipaddress {
{{ keepalived_ipv4 }} dev {{ keepalived_interface }} scope global
}
{% endif %}
{% if keepalived_ipv6 | length > 0 %}
virtual_ipaddress_excluded {
{{ keepalived_ipv6 }} dev {{ keepalived_interface }} scope global
}
{% endif %}
2023-10-10 13:22:58 +00:00
{% if keepalived_notify_enable %}
notify /etc/keepalived/notify.bash
{% endif %}
2023-04-12 12:09:46 +00:00
{% if keepalived_track_scripts | length > 0 %}
track_script {
{% for script in keepalived_track_scripts %}
{{ script.name }}
{% endfor%}
}
{% endif %}
{% if keepalived_track_processes | length > 0 %}
track_process {
{% for process in keepalived_track_processes %}
{{ process.name }}
{% endfor %}
}
{% endif %}
}