# gather factCisco Catalyst 9300 regarding l2\_interfaces

**URL:** <https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261>\
**Category:** Ansible Project\
**Created:** [January 28, 2022, 4:55pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261 "2022-01-28T16:55:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [January 28, 2022, 4:55pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/1 "2022-01-28T16:55:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [January 31, 2022, 12:35pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/2 "2022-01-31T12:35:20Z")

</div>

Hi Lucio,

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

Regards,  
Sagar Paul

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [February 1, 2022, 3:44pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/3 "2022-02-01T15:44:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [February 4, 2022, 10:01am UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/4 "2022-02-04T10:01:10Z")

</div>

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

````auto

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*
````

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [February 4, 2022, 12:23pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/5 "2022-02-04T12:23:14Z")

</div>

Hi Saga,

Actually there is.

The configuration is being applied using source templates.

Regards,

Lucio Jankok

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [February 4, 2022, 12:58pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/6 "2022-02-04T12:58:39Z")

</div>

Hey Lucio,

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

Regards,

Sagar Paul  
_E - [sag…@redhat.com](https://groups.google.com/) GH - KB-perByte_

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [February 4, 2022, 2:44pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/7 "2022-02-04T14:44:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [February 7, 2022, 11:42am UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/8 "2022-02-07T11:42:12Z")

</div>

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](https://github.com/ansible-collections/cisco.ios/issues) for an update on the scope of the module.

Regards,

Sagar Paul  
_E - [sagpaul@redhat.com](https://groups.google.com/) GH - KB-perByte_

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [February 8, 2022, 7:48am UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/9 "2022-02-08T07:48:46Z")

</div>

Thank you Sagar!  
Much appreciated.

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [March 6, 2022, 10:34am UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/10 "2022-03-06T10:34:16Z")

</div>

Hi Sagar,

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

Regards,

Lucio Jankok

---

<div class="post-metadata">

**Author:** ![KB-perByte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kb-perbyte/32/541_2.png) [@KB-perByte](https://forum.ansible.com/u/KB-perByte)\
**Post date:** [March 6, 2022, 1:52pm UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/11 "2022-03-06T13:52:33Z")

</div>

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](https://github.com/ansible-collections/cisco.ios/blob/main/plugins/module_utils/network/ios/facts/l2_interfaces/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](https://github.com/ansible-collections/cisco.ios/blob/main/plugins/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py) [_to use the structured data and deal with want and have on the basis of states_]  
argspec file - [l2\_interfaces.py](https://github.com/ansible-collections/cisco.ios/blob/main/plugins/module_utils/network/ios/argspec/l2_interfaces/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](https://github.com/ansible-network/cli_rm_builder/blob/main/docs/rm_dev_guide.md) to get started and understand the collection better, the doc should help you with getting started, and use [cli\_rm\_builder](https://github.com/ansible-network/cli_rm_builder) to generate the boilerplate code to start with the development. You may address the PR with the [issue](https://github.com/ansible-collections/cisco.ios/issues/512) tagged.

Regards,

Sagar Paul

_E - [sagpaul@redhat.com](https://groups.google.com/) GH - KB-perByte_

---

<div class="post-metadata">

**Author:** ![L\_Jankok](https://avatars.discourse-cdn.com/v4/letter/l/90db22/32.png) [@L\_Jankok](https://forum.ansible.com/u/L_Jankok)\
**Post date:** [March 10, 2022, 10:18am UTC](https://forum.ansible.com/t/gather-factcisco-catalyst-9300-regarding-l2-interfaces/36261/12 "2022-03-10T10:18:20Z")

</div>

Thanks Sagar!!
