ansible-collections / cisco.nxos

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

Enable fabric forwarding with cisco.nxos.nxos_feature fails #213

Closed roundtripdelay closed 3 years ago

roundtripdelay commented 3 years ago
SUMMARY

When trying to enable the NX-OS feature fabric forwarding, cisco.nxos.nxos_feature reports invalid feature name. This feature does exist in NX-OS and can successfully configure it from CLI:

mgmtsw01(config)# feature fabric forwarding mgmtsw01(config)# show run | i fabric feature fabric forwarding

ansible-playbook output:

failed: [mgmtsw01] (item={'feature': 'fabric forwarding', 'state': 'enabled'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "features_currently_supported": {
        "Flexlink": "disabled",
        "analytics": "disabled",
        "bash-shell": "disabled",
        "bfd": "enabled",
        "bgp": "enabled",
        "bulkstat": "disabled",
        "cable-management": "disabled",
        "catena": "disabled",
        "container-tracker": "disabled",
        "dhcp": "enabled",
        "dot1x": "disabled",
        "eigrp": "disabled",
        "eth-port-sec": "disabled",
        "evb": "disabled",
        "evc": "disabled",
        "evmed": "disabled",
        "fabric-access": "disabled",
        "fabric_mcast": "disabled",
        "fport-channel-trunk": "disabled",
        "grpc": "disabled",
        "hardware-telemetry": "disabled",
        "hmm": "enabled",
        "hsrp_engine": "disabled",
        "icam": "disabled",
        "imp": "disabled",
        "interface-vlan": "enabled",
        "isis": "disabled",
        "itd": "disabled",
        "l2vpn": "disabled",
        "l3vpn": "disabled",
        "lacp": "enabled",
        "ldap": "disabled",
        "ldp": "disabled",
        "license-smart": "disabled",
        "lldp": "enabled",
        "macsec": "disabled",
        "mpls-evpn": "disabled",
        "mpls_oam": "disabled",
        "mpls_static": "disabled",
        "msdp": "disabled",
        "mvpn": "disabled",
        "mvrp": "disabled",
        "nat": "disabled",
        "nbm": "disabled",
        "netconf": "disabled",
        "netflow": "disabled",
        "ngmvpn": "disabled",
        "ngoam": "disabled",
        "npiv": "disabled",
        "nve": "enabled",
        "nxapi": "enabled",
        "nxsdk_app1": "disabled",
        "nxsdk_app10": "disabled",
        "nxsdk_app11": "disabled",
        "nxsdk_app12": "disabled",
        "nxsdk_app13": "disabled",
        "nxsdk_app14": "disabled",
        "nxsdk_app15": "disabled",
        "nxsdk_app16": "disabled",
        "nxsdk_app17": "disabled",
        "nxsdk_app18": "disabled",
        "nxsdk_app19": "disabled",
        "nxsdk_app2": "disabled",
        "nxsdk_app20": "disabled",
        "nxsdk_app21": "disabled",
        "nxsdk_app22": "disabled",
        "nxsdk_app23": "disabled",
        "nxsdk_app24": "disabled",
        "nxsdk_app25": "disabled",
        "nxsdk_app26": "disabled",
        "nxsdk_app27": "disabled",
        "nxsdk_app28": "disabled",
        "nxsdk_app29": "disabled",
        "nxsdk_app3": "disabled",
        "nxsdk_app30": "disabled",
        "nxsdk_app31": "disabled",
        "nxsdk_app32": "disabled",
        "nxsdk_app4": "disabled",
        "nxsdk_app5": "disabled",
        "nxsdk_app6": "disabled",
        "nxsdk_app7": "disabled",
        "nxsdk_app8": "disabled",
        "nxsdk_app9": "disabled",
        "nxsdk_mgr": "disabled",
        "ofm": "disabled",
        "onep": "disabled",
        "openflow": "disabled",
        "ospf": "enabled",
        "ospfv3": "disabled",
        "pbr": "disabled",
        "pim": "enabled",
        "pim6": "disabled",
        "plb": "disabled",
        "poe": "disabled",
        "private-vlan": "disabled",
        "privilege": "disabled",
        "ptp": "disabled",
        "restconf": "disabled",
        "rip": "disabled",
        "rise": "disabled",
        "scheduler": "disabled",
        "scpServer": "enabled",
        "segment-routing": "disabled",
        "sflow": "disabled",
        "sftpServer": "disabled",
        "sla_responder": "disabled",
        "sla_sender": "disabled",
        "sla_twamp": "disabled",
        "smart-channel": "disabled",
        "srte": "disabled",
        "srv6": "disabled",
        "sshServer": "enabled",
        "tacacs": "disabled",
        "telemetry": "disabled",
        "telnetServer": "disabled",
        "tun_enc_mgr": "disabled",
        "tunnel": "disabled",
        "udld": "disabled",
        "vmtracker": "disabled",
        "vni": "disabled",
        "vnseg_vlan": "enabled",
        "vpc": "disabled",
        "vrrp": "disabled",
        "vrrpv3": "disabled",
        "vtp": "disabled"
    },
    "invalid_feature": "fabric forwarding",
    "invocation": {
        "module_args": {
            "feature": "fabric forwarding",
            "provider": null,
            "state": "enabled"
        }
    },
    "item": {
        "feature": "fabric forwarding",
        "state": "enabled"
    },
    "msg": "Invalid feature name."
}

I noticed that feature 'hmm' becomes enabled when manually configuring fabric forwarding. So I re-ran trying to enable hmm and get the following error:

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_cisco.nxos.nxos_feature_payload_3Vdlvw/ansible_cisco.nxos.nxos_feature_payload.zip/ansible_collections/cisco
/nxos/plugins/module_utils/network/nxos/nxos.py", line 726, in load_config
    resp = self.edit_config(commands, replace=replace)
  File "/tmp/ansible_cisco.nxos.nxos_feature_payload_3Vdlvw/ansible_cisco.nxos.nxos_feature_payload.zip/ansible_collections/cisco/nxos/plugins/module_utils/network/nxos/nxos.py", line 762, in edit_config
    responses = self._connection.send_request(candidate, output="config")
  File "/tmp/ansible_cisco.nxos.nxos_feature_payload_3Vdlvw/ansible_cisco.nxos.nxos_feature_payload.zip/ansible/module_utils/connection.py", line 195, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
failed: [mgmtsw01] (item={'feature': 'hmm', 'state': 'enabled'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "feature": "hmm",
            "provider": null,
            "state": "enabled"
        }
    },
    "item": {
        "feature": "hmm",
        "state": "enabled"
    },
    "msg": ": CLI execution error: % Invalid command\n"
}

If I manually configure 'feature fabric forwarding' from the CLI and re-run the task to enable feature hmm, it passes as OK!

ok: [mgmtsw01] => (item={'feature': 'hmm', 'state': 'enabled'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "commands": [],
    "invocation": {
        "module_args": {
            "feature": "hmm",
            "provider": null,
            "state": "enabled"
        }
    },
    "item": {
        "feature": "hmm",
        "state": "enabled"
    }
}
ISSUE TYPE
COMPONENT NAME

cisco.nxos.nxos_feature

ANSIBLE VERSION
ansible 2.10.2
  config file = /home/ansible/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/ansible-venv/lib64/python3.6/site-packages/ansible
  executable location = /home/ansible/ansible-venv/bin/ansible
  python version = 3.6.8 (default, Aug  7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
COLOR_DEBUG(/home/ansible/ansible.cfg) = bright gray
GALAXY_ROLE_SKELETON(/home/ansible/ansible.cfg) = /home/ansible/roles/.skel
HOST_KEY_CHECKING(/home/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Target device is a Nexus C93108TC-FX switch running NX-OS software release 9.3(3)

STEPS TO REPRODUCE
Task:
- name: Manage features in NXOS switches
  cisco.nxos.nxos_feature:
    feature: "{{ item.feature }}"
    state: "{{ item.state }}"
  loop: "{{ nxos_features }}"
  tags: features

Host_vars:
nxos_feature_maps:
  mgmtsw:
    - { feature: nxapi, state: enabled }
    - { feature: scp-server, state: enabled }
    - { feature: ospf, state: enabled }
    - { feature: bgp, state: enabled }
    - { feature: pim, state: enabled }
    - { feature: hmm, state: enabled }
#    - { feature: fabric forwarding, state: enabled }
    - { feature: interface-vlan, state: enabled }
    - { feature: vn-segment-vlan-based, state: enabled }
    - { feature: lacp, state: enabled }
    - { feature: dhcp, state: enabled }
    - { feature: lldp, state: enabled }
    - { feature: bfd, state: enabled }
    - { feature: nv overlay, state: enabled }
EXPECTED RESULTS

Expect 'feature fabric forwarding' to be configured when passing the module feature 'fabric forwarding' or 'hmm'.

ACTUAL RESULTS
See output from Summary.
NilashishC commented 3 years ago

@roundtripdelay The nxos_feature module checks the output of show feature to determine if the feature that the user is trying to configure is supported by the device or not. It seems that fabric forwarding does not appear in that list, thereby resulting in the Invalid feature name. error. To confirm this, can you please share the output of show feature from the target device?

NilashishC commented 3 years ago

Also, running feature hmm on the CLI gives an invalid command error, which is what the module throws back.

Nexus9000v(config)# show ver | in NXOS
 NXOS: version 9.3(3)
  NXOS image file is: bootflash:///nxos.9.3.3.bin
  NXOS compile time:  12/22/2019 2:00:00 [12/22/2019 14:00:37]
Nexus9000v(config)# feature hmm
                             ^
% Invalid command at '^' marker.
Nexus9000v(config)#

However, when feature fabric forwarding is enabled, the hmm feature is enabled with it and it appears in the output of show feature as enabled as well. This is why the module doesn't send the feature hmm command even though it is mentioned in the task. Hence, we don't get the CLI execution error: % Invalid command error.

Nexus9000v(config)# no feature fabric forwarding
Nexus9000v(config)# show feature | in hmm
hmm                    1          disabled
Nexus9000v(config)# feature fabric forwarding
Nexus9000v(config)# show feature | in hmm
hmm                    1          enabled
roundtripdelay commented 3 years ago

Yes, I noticed that the module works this way and 'show feature' doesn't show 'fabric forwarding'. So maybe this is WAI. Below is the output from 'show feature'

Feature Name          Instance  State
--------------------  --------  --------
Flexlink               1          disabled
analytics              1          disabled
bash-shell             1          disabled
bfd                    1          enabled
bgp                    1          enabled(not-running)
bulkstat               1          disabled
cable-management       1          disabled
catena                 1          disabled
container-tracker      1          disabled
macsec                 1          disabled
dhcp                   1          enabled
dot1x                  1          disabled
eigrp                  1          disabled
eigrp                  2          disabled
eigrp                  3          disabled
eigrp                  4          disabled
eigrp                  5          disabled
eigrp                  6          disabled
eigrp                  7          disabled
eigrp                  8          disabled
eigrp                  9          disabled
eigrp                  10         disabled
eigrp                  11         disabled
eigrp                  12         disabled
eigrp                  13         disabled
eigrp                  14         disabled
eigrp                  15         disabled
eigrp                  16         disabled
eth-port-sec           1          disabled
evb                    1          disabled
evc                    1          disabled
evmed                  1          disabled
fabric-access          1          disabled
fabric_mcast           1          disabled
fport-channel-trunk    1          disabled
grpc                   1          disabled
hardware-telemetry     1          disabled
hmm                    1          enabled
hsrp_engine            1          disabled
icam                   1          disabled
imp                    1          disabled
interface-vlan         1          enabled
isis                   1          disabled
isis                   2          disabled
isis                   3          disabled
isis                   4          disabled
isis                   5          disabled
isis                   6          disabled
isis                   7          disabled
isis                   8          disabled
isis                   9          disabled
isis                   10         disabled
isis                   11         disabled
isis                   12         disabled
isis                   13         disabled
isis                   14         disabled
isis                   15         disabled
isis                   16         disabled
itd                    1          disabled
l2vpn                  1          disabled
l3vpn                  1          disabled
lacp                   1          enabled
ldap                   1          disabled
ldp                    1          disabled
license-smart          1          disabled
lldp                   1          enabled
mpls-evpn              1          disabled
mpls_oam               1          disabled
mpls_static            1          disabled
msdp                   1          disabled
mvpn                   1          disabled
mvrp                   1          disabled
nat                    1          disabled
nbm                    1          disabled
netconf                1          disabled
netflow                1          disabled
ngmvpn                 1          disabled
ngoam                  1          disabled
npiv                   1          disabled
nve                    1          enabled
nxapi                  1          enabled
nxsdk_app1             1          disabled
nxsdk_app10            1          disabled
nxsdk_app11            1          disabled
nxsdk_app12            1          disabled
nxsdk_app13            1          disabled
nxsdk_app14            1          disabled
nxsdk_app15            1          disabled
nxsdk_app16            1          disabled
nxsdk_app17            1          disabled
nxsdk_app18            1          disabled
nxsdk_app19            1          disabled
nxsdk_app2             1          disabled
nxsdk_app20            1          disabled
nxsdk_app21            1          disabled
nxsdk_app22            1          disabled
nxsdk_app23            1          disabled
nxsdk_app24            1          disabled
nxsdk_app25            1          disabled
nxsdk_app26            1          disabled
nxsdk_app27            1          disabled
nxsdk_app28            1          disabled
nxsdk_app29            1          disabled
nxsdk_app3             1          disabled
nxsdk_app30            1          disabled
nxsdk_app31            1          disabled
nxsdk_app32            1          disabled
nxsdk_app4             1          disabled
nxsdk_app5             1          disabled
nxsdk_app6             1          disabled
nxsdk_app7             1          disabled
nxsdk_app8             1          disabled
nxsdk_app9             1          disabled
nxsdk_mgr              1          disabled
ofm                    1          disabled
onep                   1          disabled
openflow               1          disabled
ospf                   1          enabled(not-running)
ospf                   2          enabled(not-running)
ospf                   3          enabled(not-running)
ospf                   4          enabled(not-running)
ospf                   5          enabled(not-running)
ospf                   6          enabled(not-running)
ospf                   7          enabled(not-running)
ospf                   8          enabled(not-running)
ospf                   9          enabled(not-running)
ospf                   10         enabled(not-running)
ospf                   11         enabled(not-running)
ospf                   12         enabled(not-running)
ospf                   13         enabled(not-running)
ospf                   14         enabled(not-running)
ospf                   15         enabled(not-running)
ospf                   16         enabled(not-running)
ospfv3                 1          disabled
ospfv3                 2          disabled
ospfv3                 3          disabled
ospfv3                 4          disabled
ospfv3                 5          disabled
ospfv3                 6          disabled
ospfv3                 7          disabled
ospfv3                 8          disabled
ospfv3                 9          disabled
ospfv3                 10         disabled
ospfv3                 11         disabled
ospfv3                 12         disabled
ospfv3                 13         disabled
ospfv3                 14         disabled
ospfv3                 15         disabled
ospfv3                 16         disabled
pbr                    1          disabled
pim                    1          enabled
pim6                   1          disabled
plb                    1          disabled
poe                    1          disabled
private-vlan           1          disabled
privilege              1          disabled
ptp                    1          disabled
restconf               1          disabled
rip                    1          disabled
rip                    2          disabled
rip                    3          disabled
rip                    4          disabled
rise                   1          disabled
scheduler              1          disabled
scpServer              1          enabled
segment-routing        1          disabled
sflow                  1          disabled
sftpServer             1          disabled
sla_responder          1          disabled
sla_sender             1          disabled
sla_twamp              1          disabled
smart-channel          1          disabled
srte                   1          disabled
srv6                   1          disabled
sshServer              1          enabled
tacacs                 1          disabled
telemetry              1          disabled
telnetServer           1          disabled
tun_enc_mgr            1          disabled
tunnel                 1          disabled
udld                   1          disabled
vmtracker              1          disabled
vni                    1          disabled
vnseg_vlan             1          enabled
vpc                    1          disabled
vrrp                   1          disabled
vrrpv3                 1          disabled
vtp                    1          disabled