role_keepalived/templates/keepalived.j2

94 lines
2.1 KiB
Plaintext
Raw 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 %}
enable_script_security
max_auto_priority 50
}
{% for script in keepalived_track_scripts %}
vrrp_script {{ script.name }} {
script {{ script.command }}
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 %}
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 %}
{% if keepalived_notify_master %}
notify_master {{ keepalived_scripts_path }}/notify_master.sh
{% endif %}
{% if keepalived_notify_backup %}
notify_backup {{ keepalived_scripts_path }}/notify_backup.sh
{% endif %}
{% if keepalived_notify_fault %}
notify_fault {{ keepalived_scripts_path }}/notify_fault.sh
{% endif %}
{% if keepalived_notify_stop %}
notify_stop {{ keepalived_scripts_path }}/notify_stop.sh
{% 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 %}
}