iosxr_l2_interfaces – Manage Layer-2 interface on Cisco IOS-XR devices
New in version 2.9.
Synopsis
- This module manages the Layer-2 interface attributes on Cisco IOS-XR devices.
Parameters
Parameter | Choices/Defaults | Comments | ||
---|---|---|---|---|
config list / elements=dictionary | A dictionary of Layer-2 interface options | |||
l2protocol list | Configures Layer 2 protocol tunneling and protocol data unit (PDU) filtering on an interface. | |||
cdp string |
| Cisco Discovery Protocol (CDP) tunneling and data unit parameters. | ||
pvst string |
| Configures the per-VLAN Spanning Tree Protocol (PVST) tunneling and data unit parameters. | ||
stp string |
| Spanning Tree Protocol (STP) tunneling and data unit parameters. | ||
vtp string |
| VLAN Trunk Protocol (VTP) tunneling and data unit parameters. | ||
l2transport boolean |
| Switchport mode access command to configure the interface as a layer 2 access | ||
name string / required | Full name of the interface/sub-interface excluding any logical unit number, e.g. GigabitEthernet0/0/0/1 or GigabitEthernet0/0/0/1.100. | |||
native_vlan integer | Configure a native VLAN ID for the trunk | |||
propagate boolean |
| Propagate Layer 2 transport events. Note that it will work only when the l2tranport option is set to TRUE | ||
q_vlan list | 802.1Q VLAN configuration. Note that it can accept either 2 VLAN IDs when configuring Q-in-Q VLAN, or it will accept 1 VLAN ID and 'any' as input list when configuring Q-in-any vlan as input. Note, that this option is valid only with respect to Sub-Interface and is not valid when configuring for Interface. | |||
state string |
| The state of the configuration after module completion |
Notes
Note
- Tested against Cisco IOS-XRv Version 6.1.3 on VIRL.
- This module works with connection
network_cli
. See the IOS-XR Platform Options.
Examples
--- # Using merged # # Before state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # ! # interface GigabitEthernet0/0/0/4 # description Test description # ! - name: Merge provided configuration with device configuration iosxr_l2_interfaces: config: - name: GigabitEthernet0/0/0/3 native_vlan: 20 - name: GigabitEthernet0/0/0/4 native_vlan: 40 l2transport: True l2protocol: - stp: tunnel - name: GigabitEthernet0/0/0/3.900 l2transport: True q_vlan: - 20 - 40 state: merged # After state: # ------------ # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 10 # l2transport # l2protocol stp tunnel # ! # ! # interface GigabitEthernet0/0/0/3.900 l2transport # dot1q vlan 20 40 # ! # Using replaced # # Before state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 10 # l2transport # l2protocol stp tunnel # ! # ! # interface GigabitEthernet0/0/0/3.900 l2transport # dot1q vlan 20 40 # ! - name: Replaces device configuration of listed interfaces with provided configuration iosxr_l2_interfaces: config: - name: GigabitEthernet0/0/0/4 native_vlan: 40 l2transport: True l2protocol: - stp: forward - name: GigabitEthernet0/0/0/3.900 q_vlan: - 20 - any state: replaced # After state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 40 # l2transport # l2protocol stp forward # ! # ! # interface GigabitEthernet0/0/0/3.900 l2transport # dot1q vlan 20 any # ! # Using overridden # # Before state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 10 # l2transport # l2protocol stp tunnel # ! # ! # interface GigabitEthernet0/0/0/3.900 l2transport # dot1q vlan 20 40 # ! - name: Override device configuration of all interfaces with provided configuration iosxr_l2_interfaces: config: - name: GigabitEthernet0/0/0/4 native_vlan: 40 l2transport: True l2protocol: - stp: forward - name: GigabitEthernet0/0/0/3.900 q_vlan: - 20 - any state: overridden # After state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 40 # l2transport # l2protocol stp forward # ! # ! # interface GigabitEthernet0/0/0/3.900 # dot1q vlan 20 any # ! # Using deleted # # Before state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 10 # l2transport # l2protocol stp tunnel # ! # ! # - name: "Delete L2 attributes of given interfaces (Note: This won't delete the interface itself)" iosxr_l2_interfaces: config: - name: GigabitEthernet0/0/0/4 state: deleted # After state: # ------------ # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # ! # Using Deleted without any config passed # "(NOTE: This will delete all of configured resource module attributes from each configured interface)" # # Before state: # ------------- # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # dot1q native vlan 20 # ! # interface GigabitEthernet0/0/0/4 # description Test description # dot1q native vlan 10 # l2transport # l2protocol stp tunnel # ! # ! - name: "Delete L2 attributes of all interfaces (Note: This won't delete the interface itself)" iosxr_l2_interfaces: state: deleted # After state: # ------------ # # viosxr#show running-config interface # interface GigabitEthernet0/0/0/3 # description Ansible Network # vrf custB # ipv4 address 10.10.0.2 255.255.255.0 # duplex half # shutdown # ! # interface GigabitEthernet0/0/0/4 # description Test description # !
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
after list | when changed | The configuration as structured data after module completion. Sample: The configuration returned will always be in the same format of the parameters above. |
before list | always | The configuration as structured data prior to module invocation. Sample: The configuration returned will always be in the same format of the parameters above. |
commands list | always | The set of commands pushed to the remote device Sample: ['interface GigabitEthernet0/0/0/2', 'command 2', 'command 3'] |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Network Team. [network]
Red Hat Support
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors
- Sumit Jaiswal (@justjais)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/iosxr_l2_interfaces_module.html