gather factCisco Catalyst 9300 regarding l2_interfaces

114 views
Skip to first unread message

L. Jankok

unread,
Jan 28, 2022, 11:55:49 AM1/28/22
to Ansible Project
Hi,

When I use the gather fact module and choose to get the l2_interfaces, it doesn't return the l2_interfaces properties. 
When I use the same playbook on catalyst 3650 (also ios-xe) I get the l2_interfaces properties. 

Is this a known issue?

Regards,

Lucio Jankok

Sagar Paul

unread,
Jan 31, 2022, 7:35:21 AM1/31/22
to Ansible Project
Hi Lucio, 

Can you please share the config that is not giving facts data?

Regards,
Sagar Paul

L. Jankok

unread,
Feb 1, 2022, 10:44:29 AM2/1/22
to Ansible Project
Hi Sagar,

The following is the case:

With the following platform I have no issues

platform: cisco WS-3850-24S
net_iostype: IOS-XE
net_version: 16.06.05

output:
net_interfaces - show me interface configuration per interface
net_neighbors - shows me Mac address etc for all connected devices
l2_interfaces - shows me interface name, switchport mode and access vlan

---

With the 9300 I don't get the complete l2_interfaces output

platform: 9300-24p
net_iostype: IOS-XE
net_version: 17.03.03

net_interfaces - show me interface configuration per interface
net_neighbors - shows me Mac address etc for all connected devices
l2_interfaces - shows me only interface name. missing switch port mode and access vlan

----

Here is the redacted config for the 9300

Building configuration...

 

Current configuration : 30751 bytes

!

!

version 17.3

service tcp-keepalives-in

service timestamps debug datetime msec localtime show-timezone

service timestamps log datetime msec localtime show-timezone

service password-encryption

service compress-config

service call-home

no platform punt-keepalive disable-kernel-core

!

hostname redacted

!

!

vrf definition Mgmt-vrf

!

address-family ipv4

exit-address-family

!

address-family ipv6

exit-address-family

!

logging discriminator CFGLOG mnemonics drops CFGLOG_LOGGEDCMD

logging buffered discriminator CFGLOG 16384 informational

no logging console

enable secret 9 redacted

!

aaa new-model

!

!

aaa group server tacacs+ AUTH

server name redacted

server name redacted

ip tacacs source-interface redacted

!

aaa authentication password-prompt "Local Password: "

aaa authentication username-prompt "Local Username: "

aaa authentication login default group AUTH local

aaa authentication enable default group AUTH enable

aaa authorization console

aaa authorization config-commands

aaa authorization exec default group AUTH local

aaa authorization commands 1 default group AUTH if-authenticated

aaa authorization commands 15 default group AUTH if-authenticated

aaa accounting exec default start-stop group AUTH

aaa accounting commands 15 default stop-only group AUTH

!

!

!

!

!

!

aaa session-id common

boot system switch all flash:packages.conf

clock timezone CET 1 0

clock summer-time CEST recurring last Sun Mar 2:00 last Sun Oct 3:00

switch 1 provision c9300-24p

switch 2 provision c9300-24p

software auto-upgrade enable

!

!

!

!

!

!

!

!

!

!

no ip domain lookup

ip domain name redacted

!

!

!

ip dhcp snooping vlan redacted

no ip dhcp snooping information option

ip dhcp snooping

login on-success log

!

!

!

!

!

!

!

vtp mode off

udld enable

 

no device-tracking logging theft

password encryption aes

!

source template redacted

!

!

!

!

!

port-channel load-balance src-dst-ip

license boot level network-advantage addon dna-advantage

license smart url cslu redacted

!

!

diagnostic bootup level complete

!

spanning-tree mode rapid-pvst

spanning-tree portfast bpduguard default

spanning-tree extend system-id

spanning-tree pathcost method long

archive

log config

  logging enable

  notify syslog contenttype plaintext

path redacted

write-memory

memory free low-watermark processor 133138

!

errdisable recovery cause udld

errdisable recovery cause bpduguard

errdisable recovery cause channel-misconfig

errdisable recovery cause link-flap

errdisable recovery cause gbic-invalid

errdisable recovery cause psecure-violation

errdisable recovery cause loopback

errdisable recovery interval 600

username redacted privilege 15 secret 9 redacted

!

redundancy

mode sso

!

!

!

!

!

!

transceiver type all

monitoring

hw-switch switch 1 logging onboard message

!

vlan redacted

name redacted

!

vlan redacted

name redacted

!

!

template redacted

spanning-tree portfast

switchport access vlan redacted

switchport mode access

load-interval 30

description redacted

!

!

interface GigabitEthernet0/0

vrf forwarding Mgmt-vrf

no ip address

shutdown

negotiation auto

!

interface GigabitEthernet1/0/1

no logging event link-status

no cdp enable

no snmp trap link-status

source template redacted

service-policy input redacted

!

interface GigabitEthernet1/0/2

no logging event link-status

shutdown

no cdp enable

no snmp trap link-status

source template redacted

service-policy input redacted

!

!

interface GigabitEthernet1/0/24

shutdown

!

interface GigabitEthernet1/1/1

!

interface GigabitEthernet1/1/2

!

interface GigabitEthernet1/1/3

!

interface GigabitEthernet1/1/4

!

i

!

line con 0

exec-timeout 30 0

logging synchronous

stopbits 1

line vty 0 4

access-class ACL-VTY in

exec-timeout 30 0

logging synchronous

transport input ssh

line vty 5 31

access-class ACL-VTY in

exec-timeout 30 0

logging synchronous

no exec

transport input ssh

!

end



Op ma 31 jan. 2022 om 13:36 schreef Sagar Paul <sag...@redhat.com>:
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/674592ac-b9c5-4b76-abba-7b3ebb720819n%40googlegroups.com.

Sagar Paul

unread,
Feb 4, 2022, 5:01:11 AM2/4/22
to Ansible Project

Hey Lucio,
as I see in the config that you have shared, there is no switchport or vlan data to parse as per the current scope of the module.
Note - 
the interface data as shared in the above config is 
```
interface GigabitEthernet1/1/4 ``` the module is supposed to generate blank facts for the device. Regards, Sagar Paul
E - sag...@redhat.com GH - KB-perByte

L. Jankok

unread,
Feb 4, 2022, 7:23:53 AM2/4/22
to Ansible Project
Hi Saga,

Actually there is.

The configuration is being applied using source templates.

Regards,

Lucio Jankok

Op vr 4 feb. 2022 om 11:01 schreef Sagar Paul <sag...@redhat.com>:

Sagar Paul

unread,
Feb 4, 2022, 7:58:39 AM2/4/22
to Ansible Project
Hey Lucio,

Can you share some details, I am not sure if I am getting it right.


Regards,
Sagar Paul
E - sag...@redhat.com GH - KB-perByte

L. Jankok

unread,
Feb 4, 2022, 9:44:51 AM2/4/22
to Ansible Project
Hi Thom,

Thank you for your time and your interest, truly appreciated.
With interface templates you will not see the vlans or other port configurations on the interface when running show run int interface-name.
To see the applied configuration on the interface the command "show derived-config" is needed.

An example:

With a normal show run you will not see all the configs applied to the switchport

testswitch01#show run interface g1/0/1

interface GigabitEthernet1/0/1

no logging event link-status

no cdp enable

no snmp trap link-status

source template ENDUSER

service-policy input PM_IN_MARK

end


To see all the configs applied to the switchport, do the following


testswitch01#show derived-config interface g1/0/1

Building configuration...

 

Derived configuration : 270 bytes

!

interface GigabitEthernet1/0/1

description ENDUSER-WORKSTATION

switchport access vlan 990

switchport mode access

no logging event link-status

load-interval 30

no cdp enable

no snmp trap link-status

spanning-tree portfast

service-policy input PM_IN_MARK

end


Op vr 4 feb. 2022 om 13:59 schreef Sagar Paul <sag...@redhat.com>:

Sagar Paul

unread,
Feb 7, 2022, 6:42:13 AM2/7/22
to Ansible Project
Hey Lucio,

The scope of the l2_interfaces module depends on the command `show running-config | section ^interface` the facts are generated with the config op from the specific command. You may want to raise a feature request here for an update on the scope of the module.


Regards,
Sagar Paul
E - sag...@redhat.com GH - KB-perByte



L. Jankok

unread,
Feb 8, 2022, 2:49:26 AM2/8/22
to Ansible Project
Thank you Sagar!
Much appreciated.

Op ma 7 feb. 2022 om 12:42 schreef Sagar Paul <sag...@redhat.com>:

L. Jankok

unread,
Mar 6, 2022, 5:34:48 AM3/6/22
to Ansible Project
Hi Sagar,

If I want to change to scope myself, can you tell me which file I need to patch?

Regards,

Lucio Jankok

Op ma 7 feb. 2022 om 12:42 schreef Sagar Paul <sag...@redhat.com>:

Sagar Paul

unread,
Mar 6, 2022, 8:53:18 AM3/6/22
to ansible...@googlegroups.com
Hey Lucio,

Hope you are doing good! 

Given our earlier conversation, the number of changes, in this case, would be significant.
As the module is an older resource module that had all the resource module states but lacks a parser file to break config data to structured data and the flexibilities of newer resource modules using RMTemplateEngine.
The changes would go in -
facts filel2_interfaces.py [ to handle the facts generation i.e breaking config data that is pulled from a specific command to structured data ]
config filel2_interfaces.py [ to use the structured data and deal with want and have on the basis of states ]
argspec file - l2_interfaces.py [ to support the attributes present or added in the module's model
these are the primary files that need change.

I would rather suggest it would be much easier as a re-write keeping the present scope of the module intact and adding new ones that you suggested and the change in command that pulls in the config data. If you are willing to re-write the module and contribute, you can use NetworkResourceModuleDevGuide to get started and understand the collection better, the doc should help you with getting started, and use cli_rm_builder to generate the boilerplate code to start with the development. You may address the PR with the issue tagged.


Regards,
Sagar Paul
E - sag...@redhat.com GH - KB-perByte

L. Jankok

unread,
Mar 10, 2022, 5:18:58 AM3/10/22
to Ansible Project
Thanks Sagar!!

Op zo 6 mrt. 2022 om 14:53 schreef Sagar Paul <sag...@redhat.com>:
Reply all
Reply to author
Forward
0 new messages