gather factCisco Catalyst 9300 regarding l2_interfaces

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

Hi Lucio,

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

Regards,
Sagar Paul

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

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 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 ``` the module is supposed to generate blank facts for the device. Regards, Sagar Paul
*E - sagpaul@redhat.com GH - KB-perByte*

Hi Saga,

Actually there is.

The configuration is being applied using source templates.

Regards,

Lucio Jankok

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

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

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 - sagpaul@redhat.com GH - KB-perByte

Thank you Sagar!
Much appreciated.

Hi Sagar,

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

Regards,

Lucio Jankok

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 file - l2_interfaces.py [ to handle the facts generation i.e breaking config data that is pulled from a specific command to structured data ]
config file - l2_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 - sagpaul@redhat.com GH - KB-perByte

Thanks Sagar!!