diff --git a/roles/keepalived/defaults/main.yml b/roles/keepalived/defaults/main.yml index ee034f3..4aeec8c 100644 --- a/roles/keepalived/defaults/main.yml +++ b/roles/keepalived/defaults/main.yml @@ -1,5 +1,6 @@ --- keepalived__virtual_addresses: {} +keepalived__virtual_routes: {} keepalived__notify_master: [] keepalived__notify_backup: [] keepalived__notify_fault: [] diff --git a/roles/keepalived/templates/keepalived.conf.j2 b/roles/keepalived/templates/keepalived.conf.j2 index c99ae10..dabd0e2 100644 --- a/roles/keepalived/templates/keepalived.conf.j2 +++ b/roles/keepalived/templates/keepalived.conf.j2 @@ -55,6 +55,15 @@ vrrp_instance instance_v4 { {{ address }} dev {{ dev }} {% endif %} {% endfor %} +{% endfor %} + } + virtual_routes { +{% for dev, addresses in keepalived__virtual_routes.items() %} +{% for address in addresses %} +{% if address | ansible.utils.ipv4 %} + {{ address }} dev {{ dev }} +{% endif %} +{% endfor %} {% endfor %} } {% if not (ipv4_enabled and ipv6_enabled) %} @@ -81,6 +90,15 @@ vrrp_instance instance_v6 { {{ address }} dev {{ dev }} {% endif %} {% endfor %} +{% endfor %} + } + virtual_routes { +{% for dev, addresses in keepalived__virtual_routes.items() %} +{% for address in addresses %} +{% if address | ansible.utils.ipv6 %} + {{ address }} dev {{ dev }} +{% endif %} +{% endfor %} {% endfor %} } {% if not (ipv4_enabled and ipv6_enabled) %}