ansible-collections/cisco.nxos

allowed vlan except

xibriz opened this issue · 1 comments

xibriz commented
SUMMARY

Trying to set the following config:
switchport trunk allowed vlan except 174-175,189-190

With the following task:

  - name: Nxos Ethernet Interface Exclude vlans
    cisco.nxos.nxos_config:
      lines:
      - switchport trunk allowed vlan except 174-175,189-190
      parents: "interface Ethernet1/25"

But the result on the switch is:
switchport trunk allowed vlan 1-173,176-188,191-4094

I am unshure if this causes the same behavior on the switch even if the statements seems to be the same.
I tried using the cisco.nxos.nxos_l2_interfaces to set the allowed_vlans but this gives an error in the except keyword.

As I understand it, the device config parser mentioned in the docs converts the line, but I can't figure out where and why.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

cisco.nxos.nxos_config
device config parser

ANSIBLE VERSION
ansible 2.9.6
  config file = /home/ubuntu/automation/edge-network/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0]

This is intended behavior. NXOS does this automatically on the device itself, not within this module. So if you are trying to be idempotent, you need to do the inversion yourself and use that command in your playbook rather than the "except" command.

switch(config)# int eth1/10
switch(config-if)# switchport
switch(config-if)# switchport mode trunk
switch(config-if)# switchport trunk allowed vlan except 174-175,189-190
switch(config-if)# show run int eth1/10

!Command: show running-config interface Ethernet1/10
!Running configuration last done at: Thu May 18 16:23:30 2023
!Time: Thu May 18 16:23:36 2023

version 10.1(1) Bios:version

interface Ethernet1/10
  switchport mode trunk
  switchport trunk allowed vlan 1-173,176-188,191-4094