access: fix VLAN database idempotency
Do not try and match the global VLAN list as printed by the switch. Instead, only try to realize the truth: there may be some VLANs added and some removed. We keep the compact_numlist filter and use it instead of the built-in vlan_parser when listing VLANs for tagged ports. This is because some switches compact 1,2,4,5,6 as 1-2,4-6 and others as 1,2,4-6 (see next commit). All of this should reduce the number of cases where Ansible reports a change in configuration where there was in fact no change.
This commit is contained in:
parent
bd4299732d
commit
6ade4f2f8a
5 changed files with 43 additions and 31 deletions
|
@ -10,7 +10,12 @@ port-channel load-balance src-dst-ip
|
|||
|
||||
ip ssh server
|
||||
|
||||
vlan {{ vlans | map(attribute='vid') | compact_numlist }}
|
||||
{% for vlan in add_vlans %}
|
||||
vlan {{ vlan }}
|
||||
{% endfor %}
|
||||
{% for vlan in del_vlans %}
|
||||
no vlan {{ vlan }}
|
||||
{% endfor %}
|
||||
|
||||
{# bond members #}
|
||||
{% for iface in interfaces | selectattr('lag') %}
|
||||
|
|
|
@ -6,8 +6,11 @@ no enable service telnet-server
|
|||
no enable service web-server http
|
||||
no enable service web-server https
|
||||
|
||||
{% for vlan_range in vlans | map(attribute='vid') | union([1]) | compact_numlist(max_per_line=19) %}
|
||||
vlan range {{ vlan_range }}
|
||||
{% for vlan in add_vlans %}
|
||||
vlan {{ vlan }}
|
||||
{% endfor %}
|
||||
{% for vlan in del_vlans | difference([1]) %} {# VLAN 1 can not be deleted #}
|
||||
no vlan {{ vlan }}
|
||||
{% endfor %}
|
||||
|
||||
{% for iface in interfaces %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue