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:
Timotej Lazar 2025-09-18 13:45:16 +02:00
parent bd4299732d
commit 6ade4f2f8a
5 changed files with 43 additions and 31 deletions

View file

@ -13,10 +13,6 @@
set_fact:
snmp_hashes: '{{ (snmp_config.stdout | from_yaml).snmpv3.hashes }}'
- name: Get switch facts
cisco.ios.ios_facts:
gather_subset: config
- name: Get SNMP users
set_fact:
snmp_current: "{{ ansible_net_config | split('\n') | select('match', '^snmp-server user '+manager.snmp_user+' public v3') }}"