From 61cdb980eaa85220a90d3507a0b9ded346d2450d Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sat, 3 Sep 2022 14:09:37 +0200 Subject: [PATCH] keepalived: add minimal support for virtual_routes --- roles/keepalived/defaults/main.yml | 1 + roles/keepalived/templates/keepalived.conf.j2 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) 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) %}