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

ansible_net_interfaces['interface']['operstatus'] contains a space

Open cbueche opened this issue 2 years ago • 9 comments

Cisco IOS XE Software, Version 17.03.04, running on C9606R. I use a simple playbook:

- name: Gather facts
  cisco.ios.ios_facts:
    gather_subset: interfaces

- debug:
  msg: "<{{ansible_net_interfaces['Vlan6']['operstatus']}}>"

Vlan6exists so the operstatus contains the expected string up.

However, the string has an empty space at the end : up . I have looked at the module source but I fail to understand where the value comes from and where to filter it.

As temporary measure I trim in my assertion, but this should probably be filtered.

Let me know what show XXXX command I should run if needed.

cbueche avatar Aug 05 '22 08:08 cbueche

Hey @cbueche Which collection version are you using?

KB-perByte avatar Aug 05 '22 08:08 KB-perByte

sorry I should have listed them :

Collection        Version
----------------- -------
ansible.netcommon 3.0.1  
ansible.utils     2.6.1  
cisco.ios         3.1.0  
cisco.nxos        3.0.0  

# .../venv/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
...
ansible.netcommon             2.6.1  
...
cisco.ios                     2.8.1  
cisco.iosxr                   2.9.0  
cisco.ise                     1.2.1  
cisco.meraki                  2.6.1  
cisco.mso                     1.4.0  
cisco.nso                     1.0.3  
cisco.nxos                    2.9.1  
cisco.ucs                     1.8.0  

cbueche avatar Aug 05 '22 08:08 cbueche

@cbueche Thanks for the prompt reply, I added a similar fix to line protocol a few days back, Apparently the case is there with operation state,

Would you please share, show ip interface (mainly) to be extra sure- show interfaces show ipv6 interface the output of the following commands from your appliance.

Regards

KB-perByte avatar Aug 05 '22 08:08 KB-perByte

Here we are, somewhat edited. To me it looks like the first like of the 2nd command (show interface Vlan 6) below contains up with a space.

REPLACED-VCE4#show ip interface Vlan 6
Vlan6 is up, line protocol is up
  Internet address is 10.x.y.33/27
  Broadcast address is 255.255.255.255
  Address determined by non-volatile memory
  MTU is 1500 bytes
  Helper addresses are 10.x.y.10
                       10.x.y.25
  Directed broadcast forwarding is disabled
  Outgoing Common access list is not set 
  Outgoing access list is not set
  Inbound Common access list is not set 
  Inbound  access list is LIC_DENY_P2P
  Proxy ARP is disabled
  Local Proxy ARP is disabled
  Security level is default
  Split horizon is enabled
  ICMP redirects are always sent
  ICMP unreachables are always sent
  ICMP mask replies are never sent
  IP fast switching is enabled
  IP Flow switching is disabled
  IP CEF switching is enabled
  IP CEF switching turbo vector
  IP Null turbo vector
  VPN Routing/Forwarding "VPRN-TE1"
  Associated unicast routing topologies:
        Topology "base", operation state is UP
  IP multicast fast switching is enabled
  IP multicast distributed fast switching is disabled
  IP route-cache flags are Fast, CEF
  Router Discovery is disabled
  IP output packet accounting is disabled
  IP access violation accounting is disabled
  TCP/IP header compression is disabled
  RTP/IP header compression is disabled
  Probe proxy name replies are disabled
  Policy routing is disabled
  Network address translation is disabled
  BGP Policy Mapping is disabled
  Input features: Access List, MCI Check
  IPv4 WCCP Redirect outbound is disabled
  IPv4 WCCP Redirect inbound is disabled
  IPv4 WCCP Redirect exclude is disabled


REPLACED-VCE4#show interface Vlan 6
Vlan6 is up, line protocol is up , Autostate Enabled
  Hardware is Ethernet SVI, address is bc5a.56ac.4a02 (bia bc5a.56ac.4a02)
  Internet address is 10.x.x.33/27
  MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive not supported 
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input 00:00:03, output 8w0d, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/375/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     0 packets input, 0 bytes, 0 no buffer
     Received 0 broadcasts (0 IP multicasts)
     0 runts, 0 giants, 0 throttles 
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
     0 packets output, 0 bytes, 0 underruns
     Output 0 broadcasts (0 IP multicasts)
     0 output errors, 1 interface resets
     0 unknown protocol drops
     0 output buffer failures, 0 output buffers swapped out

cbueche avatar Aug 05 '22 09:08 cbueche

ethernet interfaces do not show up the space, but vlans do :

REPLACED-VCE4#show interface | inc line protocol is up     
Vlan2 is up, line protocol is up , Autostate Enabled
Vlan4 is up, line protocol is up , Autostate Enabled
Vlan6 is up, line protocol is up , Autostate Enabled
Vlan92 is up, line protocol is up , Autostate Enabled
Vlan93 is up, line protocol is up , Autostate Enabled
Vlan120 is up, line protocol is up , Autostate Enabled
Vlan121 is up, line protocol is up , Autostate Enabled
Vlan191 is up, line protocol is up , Autostate Enabled
Vlan220 is up, line protocol is up , Autostate Enabled
Vlan221 is up, line protocol is up , Autostate Enabled
Vlan291 is up, line protocol is up , Autostate Enabled
Vlan501 is up, line protocol is up , Autostate Enabled
Vlan502 is up, line protocol is up , Autostate Enabled
TwentyFiveGigE1/1/0/1 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/2 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/45 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/46 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/47 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48.3800 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48.3802 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48.3852 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48.3898 is up, line protocol is up (connected) 
TwentyFiveGigE1/1/0/48.3899 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/1 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/2 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/45 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/46 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/47 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48.3900 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48.3902 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48.3952 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48.3998 is up, line protocol is up (connected) 
TwentyFiveGigE2/1/0/48.3999 is up, line protocol is up (connected) 
Port-channel1 is up, line protocol is up (connected) 
Port-channel2 is up, line protocol is up (connected) 
Loopback3899 is up, line protocol is up 

cbueche avatar Aug 05 '22 09:08 cbueche

@cbueche Thanks for the details I would take a look at it asap

KB-perByte avatar Aug 05 '22 10:08 KB-perByte

Hey @cbueche sorry for the delayed response. Can you please check the issue with the latest release 3.3.1, I don't see it on my end. We may proceed to close the issue on your confirmation. Regards

KB-perByte avatar Sep 23 '22 12:09 KB-perByte

Hi, I tested with 3.3.2 and the bug is still present. Look on the 2nd line below, the space between up and the comma.

REPLACED-VCE4#show interface Vlan 6
Vlan6 is up, line protocol is up , Autostate Enabled

in Playbook :

    - debug:
        msg: "<{{ansible_net_interfaces['Vlan6']['operstatus']}}>"

resulting in the space still present in the operstatus value :

MSG:

<up >

but maybe I do something wrong... where is the commit that is supposedly fixing this issue ?

cbueche avatar Sep 26 '22 12:09 cbueche

@cbueche I wanted to fix this in the last release but my local assertions didn't have the tailing whitespace. I would have a look again. Sorry for the inconvenience caused

KB-perByte avatar Sep 27 '22 12:09 KB-perByte