alliedtelesis / ansible_awplus

Ansible Network Collection for AlliedWare Plus devices
GNU General Public License v3.0
10 stars 7 forks source link

awplus_l2_interfaces does not properly add new vlans to a trunk port #46

Open infcs opened 2 years ago

infcs commented 2 years ago

If you have a config for a trunk port, e.g

- name: Replace device configuration with provided configuration
  alliedtelesis.awplus.awplus_l2_interfaces:
    config:
      - name: port1.0.3
        trunk:
          allowed_vlans: 3,4,8
    state: replaced

and apply this to the switch, it works if the interface was not configured yet. If you then change the config to:

- name: Replace device configuration with provided configuration
  alliedtelesis.awplus.awplus_l2_interfaces:
    config:
      - name: port1.0.3
        trunk:
          allowed_vlans: 3,4,5,8
    state: replaced

I.e. you add another vlan to the list in this example vlan 5, you end up with an interface that has only vlan 5 configured. The other vlans are gone. If you apply the configuration again it will readd 3,4 and 8 but will remove vlan 5 again.

This happens because in replace mode, it first removes all vlans with "switchport trunk allowed vlan none" and than adds only those vlans which were missing.

First removing all vlans from an interface at runtime is quite a bad idea anyway because it disrupts traffic on the switch. If you are reconfigure the interface where your ssh traffic is going through you will likely saw off the branch your sitting on.

tony-vanderpeet commented 2 years ago

Thanks for raising this issue, I will take a look into it.

Tony van der Peet

tony-vanderpeet commented 2 years ago

This issue has been fixed in this repo, and a new collection (v1.2.1) has been uploaded onto the Galaxy site. This issue uncovered a few other issues, hence the time it took to get it fixed. Changes made include: