From 1b3218cae21b1132321adae850db11dc1871baca Mon Sep 17 00:00:00 2001 From: Seb <55829631+sdargoeuves@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:25:26 +0100 Subject: [PATCH] Change VRRP preempt default value to True (#1419) The 'vrrp.preempt' parameter did not have a well-defined default value, and the configuration templates implemented it haphazardly using different default values. This commit: * Defines the default value as True (preemption is enabled) * Modifies all relevant configuration templates to enable or disable VRRP preemption based on the 'vrrp preempt' parameter --------- Co-authored-by: Seb d'Argoeuves Co-authored-by: Ivan Pepelnjak --- docs/module/gateway.md | 2 +- netsim/ansible/templates/gateway/arubacx.j2 | 2 +- netsim/ansible/templates/gateway/cumulus.j2 | 4 +++- netsim/ansible/templates/gateway/dellos10.j2 | 2 +- netsim/ansible/templates/gateway/eos.j2 | 4 +++- netsim/ansible/templates/gateway/frr.vrrp-config.j2 | 4 +++- netsim/ansible/templates/gateway/ios.j2 | 4 +++- netsim/ansible/templates/gateway/nxos.j2 | 4 +++- netsim/ansible/templates/gateway/sros.j2 | 2 +- netsim/ansible/templates/gateway/vyos.j2 | 2 +- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/module/gateway.md b/docs/module/gateway.md index 75e074dd0..db6396c57 100644 --- a/docs/module/gateway.md +++ b/docs/module/gateway.md @@ -92,6 +92,6 @@ More complex topologies, such as multiple VRRPv3 instances *on the same subnet*, * **vrrp.group** (default: 1) -- VRRP group * **vrrp.priority** (interface parameter, integer) -* **vrrp.preempt** (interface parameter, boolean) +* **vrrp.preempt** (interface parameter, boolean) -- VRRP preempting is enabled by default; you can disable it with **vrrp.preempt: False**. No other aspect of VRRP (VRRP version, timers...) is manageable through *netlab* parameters; if you want to configure them, create a plugin to implement additional VRRP functionality. diff --git a/netsim/ansible/templates/gateway/arubacx.j2 b/netsim/ansible/templates/gateway/arubacx.j2 index 52053c702..effae4a41 100644 --- a/netsim/ansible/templates/gateway/arubacx.j2 +++ b/netsim/ansible/templates/gateway/arubacx.j2 @@ -30,7 +30,7 @@ interface {{ intf.ifname }} address fe80::1 primary address {{ intf.gateway[af]|ipaddr('address') }} secondary {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} preempt {% else %} no preempt diff --git a/netsim/ansible/templates/gateway/cumulus.j2 b/netsim/ansible/templates/gateway/cumulus.j2 index 538cf51a8..3cbfb6d12 100644 --- a/netsim/ansible/templates/gateway/cumulus.j2 +++ b/netsim/ansible/templates/gateway/cumulus.j2 @@ -24,8 +24,10 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} vrrp {{ intf.gateway.vrrp.group }} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} vrrp {{ intf.gateway.vrrp.group }} preempt +{% else %} + no vrrp {{ intf.gateway.vrrp.group }} preempt {% endif %} {% endfor %} do write diff --git a/netsim/ansible/templates/gateway/dellos10.j2 b/netsim/ansible/templates/gateway/dellos10.j2 index 15c6f26be..76d65a079 100644 --- a/netsim/ansible/templates/gateway/dellos10.j2 +++ b/netsim/ansible/templates/gateway/dellos10.j2 @@ -35,7 +35,7 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if not intf.gateway.vrrp.preempt|default(False) %} +{% if not intf.gateway.vrrp.preempt|default(True) %} no preempt {% endif %} {% endfor %} diff --git a/netsim/ansible/templates/gateway/eos.j2 b/netsim/ansible/templates/gateway/eos.j2 index e00ef18fb..9c6119757 100644 --- a/netsim/ansible/templates/gateway/eos.j2 +++ b/netsim/ansible/templates/gateway/eos.j2 @@ -19,8 +19,10 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} vrrp {{ intf.gateway.vrrp.group }} priority-level {{ intf.gateway.vrrp.priority }} {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} vrrp {{ intf.gateway.vrrp.group }} preempt +{% else %} + no vrrp {{ intf.gateway.vrrp.group }} preempt {% endif %} {% endif %} {% endfor %} diff --git a/netsim/ansible/templates/gateway/frr.vrrp-config.j2 b/netsim/ansible/templates/gateway/frr.vrrp-config.j2 index d713711d1..48ac89f49 100644 --- a/netsim/ansible/templates/gateway/frr.vrrp-config.j2 +++ b/netsim/ansible/templates/gateway/frr.vrrp-config.j2 @@ -6,8 +6,10 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} vrrp {{ intf.gateway.vrrp.group }} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} vrrp {{ intf.gateway.vrrp.group }} preempt +{% else %} + no vrrp {{ intf.gateway.vrrp.group }} preempt {% endif %} {% for af in 'ipv4','ipv6' if af in intf.gateway %} vrrp {{ intf.gateway.vrrp.group }} {{ af|replace('ipv4','ip') }} {{ intf.gateway[af]|ipaddr('address') }} diff --git a/netsim/ansible/templates/gateway/ios.j2 b/netsim/ansible/templates/gateway/ios.j2 index 9fe068b0e..b434b79ec 100644 --- a/netsim/ansible/templates/gateway/ios.j2 +++ b/netsim/ansible/templates/gateway/ios.j2 @@ -14,8 +14,10 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} preempt +{% else %} + no preempt {% endif %} {% endfor %} {% endif %} diff --git a/netsim/ansible/templates/gateway/nxos.j2 b/netsim/ansible/templates/gateway/nxos.j2 index 1a3a8e1b8..e74fd7e45 100644 --- a/netsim/ansible/templates/gateway/nxos.j2 +++ b/netsim/ansible/templates/gateway/nxos.j2 @@ -16,8 +16,10 @@ interface {{ intf.ifname }} {% if 'priority' in intf.gateway.vrrp %} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if intf.gateway.vrrp.preempt|default(False) %} +{% if intf.gateway.vrrp.preempt|default(True) %} preempt +{% else %} + no preempt {% endif %} {% endif %} {% endfor %} diff --git a/netsim/ansible/templates/gateway/sros.j2 b/netsim/ansible/templates/gateway/sros.j2 index 33834aa99..ae5da3a32 100644 --- a/netsim/ansible/templates/gateway/sros.j2 +++ b/netsim/ansible/templates/gateway/sros.j2 @@ -22,7 +22,7 @@ updates: mac: {{ intf.gateway.anycast.mac|hwaddr('linux') }} {% endif %} {% if intf.gateway.protocol == 'vrrp' %} - preempt: {{ intf.gateway.vrrp.preempt|default(False)|bool }} + preempt: {{ intf.gateway.vrrp.preempt|default(True)|bool }} {% if 'priority' in intf.gateway.vrrp %} priority: {{ intf.gateway.vrrp.priority }} {% endif %} diff --git a/netsim/ansible/templates/gateway/vyos.j2 b/netsim/ansible/templates/gateway/vyos.j2 index f430fc2ae..6daa46d7c 100644 --- a/netsim/ansible/templates/gateway/vyos.j2 +++ b/netsim/ansible/templates/gateway/vyos.j2 @@ -19,7 +19,7 @@ set high-availability vrrp group {{ vrrp_name }} address {{ intf.gateway[af] }} {% if 'priority' in intf.gateway.vrrp %} set high-availability vrrp group {{ vrrp_name }} priority {{ intf.gateway.vrrp.priority }} {% endif %} -{% if not intf.gateway.vrrp.preempt|default(False) %} +{% if not intf.gateway.vrrp.preempt|default(True) %} set high-availability vrrp group {{ vrrp_name }} no-preempt {% endif %}