ansible-collections / cisco.nxos

Ansible Network Collection for Cisco NXOS
GNU General Public License v3.0
116 stars 109 forks source link

Cannot enable Interface VLAN in NXOS #539

Closed oldguardmd closed 1 year ago

oldguardmd commented 2 years ago
SUMMARY

If you configure a VLAN using nxos_vlan and configure an IP with nxos_l3_interfaces, there appears to be no way to enable the interface VLAN

ISSUE TYPE
COMPONENT NAME

Have tried the following: nxos_vlans nxos_l3_interfaces nxos_interfaces

ANSIBLE VERSION
ansible 2.10.8
  config file = None
  configured module search path = ['/root/.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.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0]
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection Version
---------- -------
cisco.nxos 1.4.0
CONFIGURATION
Nothing returned
OS / ENVIRONMENT
Cisco Nexus Operating System (NX-OS) Software
Nexus 9000v is a demo version of the Nexus Operating System

Software
  BIOS: version
  NXOS: version 10.2(1) [Feature Release]
  BIOS compile time:
  NXOS image file is: bootflash:///nxos.10.2.1.F.bin
  NXOS compile time:  8/23/2021 17:00:00 [08/24/2021 02:33:32]

Running in CML 2.2.2
STEPS TO REPRODUCE

Inventory file example can be found here: https://github.com/CiscoSE/nxos-ansible-examples/blob/AlittleBroken/MG-Demo/public.inventory.ini

Playbook can be found here: https://github.com/CiscoSE/nxos-ansible-examples/blob/AlittleBroken/MG-Demo/configDemo.yaml

Task can be found here: https://github.com/CiscoSE/nxos-ansible-examples/blob/AlittleBroken/MG-Demo/tasks/task-CreateVLANs.yaml

EXPECTED RESULTS

Ultimately I think that when I use nxos_l3_interfaces, there should be a switch to set the interface vlan to enabled:

- name: Assign IP to VLAN 10 (Core1)
  nxos_l3_interfaces:
    config:
    - name: vlan10
      ipv4:
      - address: 192.168.60.1/25
    state: merged

But if the intent is to do all interface shut and no shut operations with nxos_interfaces, then that needs to work. And I would suggest providing an example under nxos_vlans that demonstrates how to create the VLAN, assign the IP, and then enable it. This is to common a task to not provide something in the way of clear guidance.

This section of my current code is suspected to be the way to do this based on other issues I reviewed, but it doesn't enable the port and returns no errors.

- name: Enable interface VLAN 10 on Core switches
  nxos_interfaces:
    config:
      - name: Vlan10
        enabled: True
  when: (role == "Core") and (ansible_network_os == 'cisco.nxos.nxos')
ACTUAL RESULTS

Completes successfully, but the interface VLAN remains in a shut state. I have to do a no shut from the CLI currently to bring up the interface vlan.

saruter commented 2 years ago

I can reproduce the errant behaviour. I can't enable a SVI with the current version of the nxos-Ansible Modules (3.10).

Trying to enable an existing SVI with Module cisco.nxos.nxos_interfaces

ok: [dev-switch] => {
    "before": [
        {
            "description": "vlan_mgmt",
            "fabric_forwarding_anycast_gateway": true,
            "mtu": "9216",
            "name": "Vlan2"
        },
],
    "changed": false,
    "commands": [],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "description": "vlan_mgmt",
                    "duplex": null,
                    "enabled": true,
                    "fabric_forwarding_anycast_gateway": true,
                    "ip_forward": null,
                    "mode": null,
                    "mtu": "9216",
                    "name": "Vlan2",
                    "speed": null
                }
            ],
            "running_config": null,
            "state": "merged"
        }
    }
}

You can see that the module config for this SVI is "enabled": true but no commands are sent to the device "commands": [].

Runtime Data: Ansible:

ansible [core 2.12.5]
  config file = /home/blub/git-workspace/ansible/VXLAN-EVPN-Datacenter/ansible.cfg
  configured module search path = ['/home/blub/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/blub/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Sep 21 2021, 00:10:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True
Collection Version
---------- -------
cisco.nxos 3.1.0  

Tested on N9kv:

Software
  BIOS: version
  NXOS: version 10.2(1) [Feature Release]
  BIOS compile time:
  NXOS image file is: bootflash:///nxos.10.2.1.F.bin
  NXOS compile time:  8/23/2021 17:00:00 [08/24/2021 04:33:32]
gve-vse-tim commented 2 years ago

Confirms this happens on Nexus 5672UP with NXOS 7.3(11)N1(1)