Closed oraclek76 closed 7 months ago
Created in error. This can be closed out. I had my syntax wrong.
Actually this one only works if I manually enter 'switchport' on the command line. Is there a way to use this to configure a port channel as layer 2? Or a way to use the lacp module to create it as a switchport/layer 2? I can open an issue under that module if it is better to do that.
Actually this one only works if I manually enter 'switchport' on the command line. Is there a way to use this to configure a port channel as layer 2? Or a way to use the lacp module to create it as a switchport/layer 2? I can open an issue under that module if it is better to do that.
Hey @oraclek76 I have had a lot of frustration with setting up port-channels or lags as well using the cisco.nexus modules. The work-around is to use "mode: layer2" with the cisco.nxos.nxos_interfaces module.
This is what I found works for port-channels.
First setup some variables, I placed them into a interfaces.yaml file in each device folder in host_vars.
interfaces:
- name: port-channel4001
description: CR0x-L2/L3-4001
mode: layer2
enabled: true
lag_interfaces:
- name: port-channel4001
members:
- member: Ethernet1/53
- member: Ethernet1/54
lag_l2_interfaces:
- name: port-channel4001
mode: trunk
trunk:
allowed_vlans: 3000-3999
Then use those variables as input to the appropriate cisco_nxos modules. In the example below, the role_action is set to merged. I think only merged and rendered work correctly. I'm using a "interfaces" role so these are just tasks in that role but you could just place them into a playbook under tasks I think.
- name: NXOS - Configure Interfaces
cisco.nxos.nxos_interfaces:
config: "{{ interfaces }}"
state: "{{ role_action }}"
register: results
when: interfaces | length > 0
- name: NXOS - Configure Port-Channel LAG Interfaces
cisco.nxos.nxos_lag_interfaces:
config: "{{ lag_interfaces }}"
state: "{{ role_action }}"
register: lag_results
when: lag_interfaces | length > 0
- name: NXOS - Configure L2 Port-Channel Interfaces
cisco.nxos.nxos_l2_interfaces:
config: "{{ lag_l2_interfaces }}"
state: "{{ role_action }}"
register: lag_results
when: lag_l2_interfaces | length > 0
I have no idea if this is how Cisco intends customers to build solutions with the cisco.nexus ansible collection, but this worked for me even if it is a hacky cludge. Good Luck!
@oraclek76 This can be easily be done through the nxos_interfaces module, which deals with interface base parameters like description, speed, admin state, mode (L2/L3), etc. Please refer to the following playbook. Note that this works for both new and existing port-channels.
---
- hosts: nxos
gather_facts: no
tasks:
- name: Mode for port-channels
cisco.nxos.nxos_interfaces:
config:
- name: Port-Channel10
mode: layer2
state: merged
With that, I'm closing this ticket. If you have more questions on this topic, please feel free to re-open this. Thank you!
SUMMARY
Can we add a feature to allow for port channels for this? Trying to create a port channel as layer 2. Maybe there is a better way to do it.
ISSUE TYPE
COMPONENT NAME
cisco.nxos.nxos_l2_interfaces
ADDITIONAL INFORMATION
When I use the command for port channels it is a layer 2 port channel and I need it to be a layer 3 port channel for it to be a peer-link for vpc.