# {{ 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 %} script_user keepalived_script 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 {% if keepalived_peers | length > 0 %} unicast_src_ip {{ ansible_facts[keepalived_interface]['ipv4']['address'] }} unicast_peer { {% for peer in keepalived_peers %} {% if peer != ansible_facts[keepalived_interface]['ipv4']['address'] %} {{ peer }} {% endif %} {% endfor %} } {% endif %} {% 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_enable %} notify /etc/keepalived/notify.bash {% endif %} {% 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 %} }