ansible-collections/cisco.nxos

When using the cisco.nxos.nxos_interfaces module when using the state replace the MTU is defaulted to 1500 if the original MTU is same as the one in the new config

digitalfiend64 opened this issue · 1 comments

SUMMARY

When using the cisco.nxos.nxos_interfaces module when using the state replace the MTU is defaulted to 1500 if the original MTU is same as the one in the new config

Example before configuration:
interface Ethernet1/28
description Auto_Cable_Testing
mtu 9216
Configuration change data model:

  • configs:            # Port turnup config block
          - interfaces:     # interface module
              - name: Ethernet1/28
                description: Ansible Port Turn Up1
                mode: layer2
                mtu: "9216"
                speed: "1000"
                duplex: full
                enabled: true

After Run through the playbook:

interface Ethernet1/28
description Ansible Port Turn Up1
switchport
speed 1000
duplex full
no shutdown

The MTU command is no longer in the running config because ansible ignores it due to idempotency.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.nxos.nxos_interfaces module

ANSIBLE VERSIO
ansible [core 2.12.6]
  config file = /home/REDACTED/.ansible.cfg
  configured module search path = ['/home/REDACTED/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/REDACTED/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.0.2
  libyaml = True

##### COLLECTION VERSION
<!--- Paste verbatim output from "ansible-galaxy collection list
<namespace>.<collection>"  between the quotes
for example: ansible-galaxy collection list community.general
-->
```paste below
collection Version
---------- -------
cisco.nxos           5.1.0
CONFIGURATION
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/REDACTED/.ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/home/REDACTED/.ansible.cfg) = yaml
DEFAULT_TIMEOUT(/home/REDACTED/.ansible.cfg) = 120
DEPRECATION_WARNINGS(/home/REDACTED/.ansible.cfg) = False
GALAXY_IGNORE_CERTS(/home/REDACTED/.ansible.cfg) = True
GALAXY_SERVER_LIST(/home/REDACTED/.ansible.cfg) = ['inbound_yeti_repo', 'published_repo', 'rh-certified_repo']
HOST_KEY_CHECKING(/home/REDACTED/.ansible.cfg) = False
PARAMIKO_HOST_KEY_AUTO_ADD(/home/REDACTED/.ansible.cfg) = True
PERSISTENT_COMMAND_TIMEOUT(/home/REDACTED/.ansible.cfg) = 300
PERSISTENT_CONNECT_TIMEOUT(/home/REDACTED/.ansible.cfg) = 120
RETRY_FILES_ENABLED(/home/REDACTED/.ansible.cfg) = False

OS / ENVIRONMENT

NXOS: version 7.0(3)I7(6)

STEPS TO REPRODUCE

Configure a defaulted port with an MTU that matches the MTU you want to config in the module

Example before configuration:
interface Ethernet1/28
description Auto_Cable_Testing
mtu 9216

Example after fact gathering:
Ethernet1/28:
bandwidth: '10000000'
description: Auto_Cable_Testing
duplex: auto
macaddress: 002a.105e.8b3b
mtu: '9216'
speed: auto-speed
state: down
type: 100/1000/10000 Ethernet
The interfaces modules ignores the MTU key because it is the same as the original but if it doesn’t add back to the config after the switchport command is set:

commands:

  • interface Ethernet1/28
  • switchport
  • description Ansible Port Turn Up1
  • speed 1000
  • duplex full
  • no shutdown
- configs:            # Port turnup config block
      - interfaces:     # interface module
          - name: Ethernet1/28
            description: Ansible Port Turn Up1
            mode: layer2
            mtu: "9216"
            speed: "1000"
            duplex: full
            enabled: true
EXPECTED RESULTS

Expect the module to send the tag variable with the IP address command regardless of if it is the same as the original

commands:

  • interface Ethernet1/28
  • switchport
  • description Ansible Port Turn Up1
  • mtu: ‘9216’
  • speed 1000
  • duplex full
  • no shutdown
ACTUAL RESULTS

commands:

  • interface Ethernet1/28
  • switchport
  • description Ansible Port Turn Up1
  • speed 1000
  • duplex full
  • no shutdown
- configs:            # Port turnup config block
      - interfaces:     # interface module
          - name: Ethernet1/28
            description: Ansible Port Turn Up1
            mode: layer2
            mtu: "9216"
            speed: "1000"
            duplex: full
            enabled: true


@digitalfiend64 This seems to be happening because changing the interface mode to layer2 (via switchport command), seems to default the MTU to 1500. However, since Ansible finds MTU set to 9216 in both the before and expected state, it doesn't explicitly set it.

I'll update this ticket when I have a solution ready.