diff --git a/roles/access/tasks/main.yml b/roles/access/tasks/main.yml index eee6521..069784c 100644 --- a/roles/access/tasks/main.yml +++ b/roles/access/tasks/main.yml @@ -18,8 +18,9 @@ # Determine VLANs to add and remove from switch. - set_fact: actual_vlans: "{{ vlans | map(attribute='vid') }}" - switch_vlans: "{{ ansible_net_config | split('\n') | select('match', '^ *vlan (range )?[0-9]') - | map('regex_search', '[0-9,-]+') | join(',') | ansible.netcommon.vlan_expander }}" + switch_vlans: "{{ ansible_net_config | split('\n') + | 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: add_vlans: "{{ actual_vlans | difference(switch_vlans) }}"