access: fix parsing of existing switch VLANs
If ansible won’t handle edge cases then we must.
This commit is contained in:
parent
6ade4f2f8a
commit
9ec6241e4a
1 changed files with 3 additions and 2 deletions
|
@ -18,8 +18,9 @@
|
||||||
# Determine VLANs to add and remove from switch.
|
# Determine VLANs to add and remove from switch.
|
||||||
- set_fact:
|
- set_fact:
|
||||||
actual_vlans: "{{ vlans | map(attribute='vid') }}"
|
actual_vlans: "{{ vlans | map(attribute='vid') }}"
|
||||||
switch_vlans: "{{ ansible_net_config | split('\n') | select('match', '^ *vlan (range )?[0-9]')
|
switch_vlans: "{{ ansible_net_config | split('\n')
|
||||||
| map('regex_search', '[0-9,-]+') | join(',') | ansible.netcommon.vlan_expander }}"
|
| select('match', '^ *vlan (range )?[0-9]') | map('regex_search', '[0-9,-]+') | join(',')
|
||||||
|
| default('0', true) | ansible.netcommon.vlan_expander | reject('eq', 0) }}" # vlan_expander barfs on empty string so add/remove a fake VLAN 0
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
add_vlans: "{{ actual_vlans | difference(switch_vlans) }}"
|
add_vlans: "{{ actual_vlans | difference(switch_vlans) }}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue