cisco.nxos icon indicating copy to clipboard operation
cisco.nxos copied to clipboard

nxos_vlans mis-parses vn-segment

Open roundtripdelay opened this issue 3 years ago • 0 comments

SUMMARY

I noticed nxos_vlans always returns changed=true. VLAN 99 in the one in question. It has the VNI configured in it's running-configuration and is defined correctly in the variable, but the module excludes it and reapplies every time the PB is run:

    "changed": true,
    "commands": [
        "vlan 99",
        "vn-segment 10099"
ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.nxos.nxos_vlans

ANSIBLE VERSION
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5
20150623 (Red Hat 4.8.5-44)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
ansible [core 2.11.2]
  config file = /home/epic/dev/infrastructure_automation/ansible/ansible.cfg
  configured module search path = ['/home/epic/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/epic/.local/lib/python3.6/site-packages/ansible
  ansible collection location = /home/epic/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/epic/.local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5
20150623 (Red Hat 4.8.5-44)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.

# /home/epic/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.nxos 2.4.0

# /home/epic/.local/lib/python3.6/site-packages/ansible_collections
Collection Version
---------- -------
cisco.nxos 2.4.0
CONFIGURATION
Switch config:
sw01# sh run | section vlan
  limit-resource vlan minimum 16 maximum 4094
feature interface-vlan
feature vn-segment-vlan-based
vlan 1,98-99,106,112,119-120,500-501,999
vlan 98
  name poap
  vn-segment 10098
vlan 99
  name drac
  vn-segment 10099
vlan 106
  name lb-mgmt
  vn-segment 10106
vlan 112
  name net-mgmt
  vn-segment 10112
vlan 119
  name unity-ipmi
  vn-segment 10119
vlan 120
  name unity-mgmt
  vn-segment 10120
vlan 500
  name infra-50500
  vn-segment 50500
vlan 501
  name drac-50501
  vn-segment 50501
vlan 999
  name blackhole

Group_vars:
nxos_vlan_maps:
  sw:
    - { vlan_id: 98, name: poap, mapped_vni: "10098" }
    - { vlan_id: 99, name: drac, mapped_vni: "10099" }
    - { vlan_id: 106, name: lb-mgmt, mapped_vni: "10106" }
    - { vlan_id: 112, name: net-mgmt, mapped_vni: "10112" }
    - { vlan_id: 119, name: unity-ipmi, mapped_vni: "10119" }
    - { vlan_id: 120, name: unity-mgmt, mapped_vni: "10120" }
    - { vlan_id: 500, name: infra-50500, mapped_vni: "50500" }
    - { vlan_id: 501, name: drac-50501, mapped_vni: "50501" }
    - { vlan_id: 999, name: blackhole }

Host_vars:
nxos_vlans: "{{ nxos_vlan_maps['sw'] }}"

Task:
- name: Configure VLANs on NX-OS device(s).
  cisco.nxos.nxos_vlans:
    config: "{{ nxos_vlans }}"
    state: merged
  tags: vlans

Playbook:
- name: Configure NX-OS devices
  hosts: "{{ target }}"
  gather_facts: no
  tasks:
    - name: Configure VLANs
      include_role:
        name: setup_network
        tasks_from: nxos_vlans
OS / ENVIRONMENT
Nexus 9000v is a demo version of the Nexus Operating System

Software
  BIOS: version
 NXOS: version 9.3(6)
  BIOS compile time:
  NXOS image file is: bootflash:///nxos.9.3.6.bin
  NXOS compile time:  11/9/2020 23:00:00 [11/10/2020 11:00:21]


Hardware
  cisco Nexus9000 C9300v Chassis
  Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz with 8161060 kB of memory.
  Processor Board ID 96QGYJD0PJW
STEPS TO REPRODUCE

Run playbook

EXPECTED RESULTS

Expect results to be Idempotent.

ACTUAL RESULTS
PLAYBOOK: setup_network.yml *********************************************************************************************************************************************************
1 plays in setup_network.yml

PLAY [Playbook to configure NX-OS devices (all-in-one)] *****************************************************************************************************************************
META: ran handlers

TASK [Configure VLANs] **************************************************************************************************************************************************************
task path: /home/epic/dev/infrastructure_automation/ansible/setup_network.yml:19
redirecting (type: action) cisco.nxos.nxos_vlans to cisco.nxos.nxos
redirecting (type: action) cisco.nxos.nxos_vlans to cisco.nxos.nxos

TASK [setup_network : Configure VLANs on NX-OS device(s).] **************************************************************************************************************************
task path: /home/epic/dev/infrastructure_automation/ansible/roles/setup_network/tasks/nxos_vlans.yml:23
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
redirecting (type: httpapi) ansible.builtin.nxos to cisco.nxos.nxos
redirecting (type: action) cisco.nxos.nxos_vlans to cisco.nxos.nxos
redirecting (type: action) cisco.nxos.nxos_vlans to cisco.nxos.nxos
<sw01> ESTABLISH LOCAL CONNECTION FOR USER: epic
<sw01> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0 `"&& mkdir "` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744 `" && echo ansible-tmp-1626384684.63077-130226-173912597140744="` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744 `" ) && sleep 0'
<sw01> Attempting python interpreter discovery
<sw01> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<sw01> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file /home/epic/.ansible/collections/ansible_collections/cisco/nxos/plugins/modules/nxos_vlans.py
<sw01> PUT /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/tmpicjwptaw TO /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744/AnsiballZ_nxos_vlans.py
<sw01> EXEC /bin/sh -c 'chmod u+x /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744/ /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744/AnsiballZ_nxos_vlans.py && sleep 0'
<sw01> EXEC /bin/sh -c '/usr/bin/python /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744/AnsiballZ_nxos_vlans.py && sleep 0'

<sw01> EXEC /bin/sh -c 'rm -f -r /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384684.63077-130226-173912597140744/ > /dev/null 2>&1 && sleep 0'
changed: [sw01] => {
    "after": [
        {
            "enabled": true,
            "mapped_vni": 50501,
            "mode": "ce",
            "name": "default",
            "state": "active",
            "vlan_id": 1
        },
        {
            "enabled": true,
            "mapped_vni": 10098,
            "mode": "ce",
            "name": "poap",
            "state": "active",
            "vlan_id": 98
        },
        {
            "enabled": true,
            "mode": "ce",
            "name": "drac",
            "state": "active",
            "vlan_id": 99
        },
        {
            "enabled": true,
            "mapped_vni": 10106,
            "mode": "ce",
            "name": "lb-mgmt",
            "state": "active",
            "vlan_id": 106
        },
        {
            "enabled": true,
            "mapped_vni": 10112,
            "mode": "ce",
            "name": "net-mgmt",
            "state": "active",
            "vlan_id": 112
        },
        {
            "enabled": true,
            "mapped_vni": 10119,
            "mode": "ce",
            "name": "unity-ipmi",
            "state": "active",
            "vlan_id": 119
        },
        {
            "enabled": true,
            "mapped_vni": 10120,
            "mode": "ce",
            "name": "unity-mgmt",
            "state": "active",
            "vlan_id": 120
        },
        {
            "enabled": true,
            "mapped_vni": 50500,
            "mode": "ce",
            "name": "infra-50500",
            "state": "active",
            "vlan_id": 500
        },
        {
            "enabled": true,
            "mapped_vni": 50501,
            "mode": "ce",
            "name": "drac-50501",
            "state": "active",
            "vlan_id": 501
        },
        {
            "enabled": true,
            "mode": "ce",
            "name": "blackhole",
            "state": "active",
            "vlan_id": 999
        }
    ],
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "before": [
        {
            "enabled": true,
            "mapped_vni": 50501,
            "name": "default",
            "state": "active",
            "vlan_id": 1
        },
        {
            "enabled": true,
            "mapped_vni": 10098,
            "name": "poap",
            "state": "active",
            "vlan_id": 98
        },
        {
            "enabled": true,
            "name": "drac",
            "state": "active",
            "vlan_id": 99
        },
        {
            "enabled": true,
            "mapped_vni": 10106,
            "name": "lb-mgmt",
            "state": "active",
            "vlan_id": 106
        },
        {
            "enabled": true,
            "mapped_vni": 10112,
            "name": "net-mgmt",
            "state": "active",
            "vlan_id": 112
        },
        {
            "enabled": true,
            "mapped_vni": 10119,
            "name": "unity-ipmi",
            "state": "active",
            "vlan_id": 119
        },
        {
            "enabled": true,
            "mapped_vni": 10120,
            "name": "unity-mgmt",
            "state": "active",
            "vlan_id": 120
        },
        {
            "enabled": true,
            "mapped_vni": 50500,
            "name": "infra-50500",
            "state": "active",
            "vlan_id": 500
        },
        {
            "enabled": true,
            "mapped_vni": 50501,
            "name": "drac-50501",
            "state": "active",
            "vlan_id": 501
        },
        {
            "enabled": true,
            "name": "blackhole",
            "state": "active",
            "vlan_id": 999
        }
    ],
    "changed": true,
    "commands": [
        "vlan 99",
        "vn-segment 10099"
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "enabled": null,
                    "mapped_vni": 10098,
                    "name": "poap",
                    "state": null,
                    "vlan_id": 98
                },
                {
                    "enabled": null,
                    "mapped_vni": 10099,
                    "name": "drac",
                    "state": null,
                    "vlan_id": 99
                },
                {
                    "enabled": null,
                    "mapped_vni": 10106,
                    "name": "lb-mgmt",
                    "state": null,
                    "vlan_id": 106
                },
                {
                    "enabled": null,
                    "mapped_vni": 10112,
                    "name": "net-mgmt",
                    "state": null,
                    "vlan_id": 112
                },
                {
                    "enabled": null,
                    "mapped_vni": 10119,
                    "name": "unity-ipmi",
                    "state": null,
                    "vlan_id": 119
                },
                {
                    "enabled": null,
                    "mapped_vni": 10120,
                    "name": "unity-mgmt",
                    "state": null,
                    "vlan_id": 120
                },
                {
                    "enabled": null,
                    "mapped_vni": 50500,
                    "name": "infra-50500",
                    "state": null,
                    "vlan_id": 500
                },
                {
                    "enabled": null,
                    "mapped_vni": 50501,
                    "name": "drac-50501",
                    "state": null,
                    "vlan_id": 501
                },
                {
                    "enabled": null,
                    "mapped_vni": null,
                    "name": "blackhole",
                    "state": null,
                    "vlan_id": 999
                }
            ],
            "running_config": null,
            "state": "merged"
        }
    }
}
META: role_complete for sw01

TASK [Save running-configuration to startup.] ***************************************************************************************************************************************
task path: /home/epic/dev/infrastructure_automation/ansible/setup_network.yml:71
redirecting (type: modules) ansible.builtin.nxos_config to cisco.nxos.nxos_config

TASK [setup_network : Save the running-configuration to startup-configuration] ******************************************************************************************************
task path: /home/epic/dev/infrastructure_automation/ansible/roles/setup_network/tasks/nxos_save_config.yml:4
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
redirecting (type: httpapi) ansible.builtin.nxos to cisco.nxos.nxos
<sw01> ESTABLISH HTTP(S) CONNECTFOR USER: admin TO https://sw01:9443
redirecting (type: action) ansible.builtin.nxos to cisco.nxos.nxos
redirecting (type: action) ansible.builtin.nxos to cisco.nxos.nxos
<sw01> ESTABLISH LOCAL CONNECTION FOR USER: epic
<sw01> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0 `"&& mkdir "` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432 `" && echo ansible-tmp-1626384712.6992638-130264-140293736451432="` echo /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.nxos_config to cisco.nxos.nxos_config
Using module file /home/epic/.ansible/collections/ansible_collections/cisco/nxos/plugins/modules/nxos_config.py
<sw01> PUT /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/tmp5_b17r62 TO /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432/AnsiballZ_nxos_config.py
<sw01> EXEC /bin/sh -c 'chmod u+x /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432/ /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432/AnsiballZ_nxos_config.py && sleep 0'
<sw01> EXEC /bin/sh -c '/usr/bin/python /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432/AnsiballZ_nxos_config.py && sleep 0'
<sw01> EXEC /bin/sh -c 'rm -f -r /home/epic/.ansible/tmp/ansible-local-130217t8p1fno0/ansible-tmp-1626384712.6992638-130264-140293736451432/ > /dev/null 2>&1 && sleep 0'
ok: [sw01] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "defaults": false,
            "diff_against": null,
            "diff_ignore_lines": null,
            "intended_config": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "provider": null,
            "replace": "line",
            "replace_src": null,
            "running_config": null,
            "save_when": "modified",
            "src": null
        }
    }
}
META: role_complete for sw01
META: ran handlers
META: ran handlers

PLAY RECAP **************************************************************************************************************************************************************************
sw01                       : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

roundtripdelay avatar Jul 15 '21 21:07 roundtripdelay