ansible-collections / dellemc.enterprise_sonic

Ansible Network Collection for Enterprise SONiC Distribution by Dell Technologies
GNU General Public License v3.0
44 stars 64 forks source link

[QUESTION]: Replacing LAG interface with L2, and vice versa #278

Closed fzakfeld closed 7 months ago

fzakfeld commented 1 year ago

How can the team help?

We need to change some interfaces from being a LAG member to being a standalone L2 port, and vice versa. Problem is that the LAG can not be configured at physical interface level, but rather the interfaces need to be configured as a 'member' on the LAG interface using sonic_lag_interfaces.

Since configuring L2 and LAG interfaces are different tasks, one is executed at first. If the L2 interfaces are configured first, then there might still be a port-channel configured on a port making the config task fail.

Is there any recommended way of handling this?

Details: ?

Our task looks like this:

- name: Set LAG Interfaces
  dellemc.enterprise_sonic.sonic_lag_interfaces:
    config: "{{ switch_ports | scaleup_sonic_lacp_interfaces }}"
    state: replaced

- name: Configure L2 Interfaces
  dellemc.enterprise_sonic.sonic_l2_interfaces:
    config: "{{ switch_ports | scaleup_sonic_l2_interfaces }}"
    state: replaced

switch_ports | scaleup_sonic_lacp_interfaces will return a list of LAG interfaces, in this case including one with Ethernet124 as the member.

switch_ports | scaleup_sonic_l2_interfaces will return a list of all L2 interfaces, without Ethernet124 (prior configured as L2 interface)

interface Ethernet124
 mtu 9100
 speed 100000
 unreliable-los auto
 no shutdown
 switchport access Vlan 1
 switchport trunk allowed Vlan 100
!

Task runs:

fatal: [redacted]: FAILED! => {
    "changed": false,
    "code": -32603,
    "invocation": {
        "module_args": {
            "config": [
                (redacted)
            ],
            "state": "replaced"
        }
    },
    "msg": "{'ietf-restconf:errors': {'error': [{'error-type': 'application', 'error-tag': 'invalid-value', 'error-app-tag': 'Config Validation Error', 'error-message': 'PortChannel configuration not allowed. Access VLAN:1 configuration exists on interface Ethernet124.', 'error-info': {'cvl-error': {'error-code': 1002, 'table-name': 'PORTCHANNEL_MEMBER', 'key-values': ['PORTCHANNEL_MEMBER', 'PortChannel255', 'Ethernet124']}}}]}, 'code': 400, 'request_data': {'path': 'data/openconfig-interfaces:interfaces/interface=Ethernet124/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id', 'method': 'patch'}}"
}
kerry-meyer commented 8 months ago

The sequencing requirement described here is due to the underlying SONiC device restrictions.

There is no obvious, safe way to automatically prevent the error in an Ansible resource module implementation. (We feel that is safest to avoid automatically inferring and applying configuration or changing the order of invocation of plays without intermediate user involvement.)

kerry-meyer commented 7 months ago

As mentioned in the previous post on this issue: The only safe way of handling the situation described here it to order the tasks to perform the configuration actions in the required order:

1) Remove port channel configuration an any interfaces that need to be configured as L2 interfaces before configuring them as L2 interfaces. 2) Remove any L2 configuration on interfaces before attempting to make them members of a port channel.

If the "batched" configuration (and de-configuration) actions as shown above are desired, then a workable implementation would be something like:

- remove lag configuration for interfaces to be configured as L2 interfaces
- Apply any desired new L2 configuration
- Remove any current L2 configuration for interfaces to be configured as lag interfaces
- Apply lag configuration for any desired new lag interfaces.
kerry-meyer commented 7 months ago

Please see the posted responses above and let us know if there are any remaining questions or specific requests for new functionality to be added.