dellemc.enterprise_sonic.sonic_stp module – Manage STP configuration on SONiC

Note

This module is part of the dellemc.enterprise_sonic collection (version 3.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install dellemc.enterprise_sonic.

To use it in a playbook, specify: dellemc.enterprise_sonic.sonic_stp.

New in dellemc.enterprise_sonic 2.3.0

Synopsis

  • This module provides configuration management of STP for devices running SONiC

Parameters

Parameter

Comments

config

dictionary

Specifies STP configurations

mstp, pvst and rapid_pvst are mutually exclusive.

global

dictionary

Global STP configuration

bpdu_filter

boolean

Enables edge port BPDU filter

Choices:

  • false

  • true

bridge_priority

integer

The manageable component of the bridge identifier

Value must be a multiple of 4096 in the range of 0-61440

disabled_vlans

list / elements=string

List of disabled STP VLANs. The value of a list item can be a single VLAN ID or a range of VLAN IDs

separated by ‘-’ or ‘..’; for example 70-100 or 70..100.

enabled_protocol

string

Specifies the type of STP enabled on the device

Choices:

  • "mst"

  • "pvst"

  • "rapid_pvst"

fwd_delay

integer

Delay in seconds used by STP bridges to transition root and designated ports to forwarding

Range 4-30

hello_time

integer

Interval in seconds between periodic transmissions of configuration messages by designated ports

Range 1-10

loop_guard

boolean

The loop guard default setting for the bridge

Choices:

  • false

  • true

max_age

integer

Maximum age in seconds of the information transmitted by the bridge when it is the root bridge

Range 6-40

portfast

boolean

Enables PortFast globally on all access ports

Configurable for pvst protocol

Choices:

  • false

  • true

root_guard_timeout

integer

Specifies root guard recovery timeout in seconds before the port is moved back to forwarding state

Range 5-600

interfaces

list / elements=dictionary

Interfaces STP configuration

bpdu_filter

boolean

Enables edge port BPDU filter

Choices:

  • false

  • true

bpdu_guard

boolean

Enable edge port BPDU guard

Choices:

  • false

  • true

cost

integer

The port’s contribution, when it is the root port, to the root path cost for the bridge

Range 1-200000000

edge_port

boolean

Configure interface as an STP edge port

Choices:

  • false

  • true

guard

string

Enables root guard or loop guard

Choices:

  • "loop"

  • "root"

  • "none"

intf_name

string / required

Name of interface

string

Specifies the interface’s link type

Choices:

  • "point-to-point"

  • "shared"

port_priority

integer

The manageable component of the port identifier

Range 0-240

portfast

boolean

Enable/Disable portfast on specified interface

Configurable for pvst protocol

Choices:

  • false

  • true

shutdown

boolean

Port to be shutdown when it receives a BPDU

Choices:

  • false

  • true

stp_enable

boolean

Enables STP on the interface

Choices:

  • false

  • true

boolean

Enables uplink fast

Choices:

  • false

  • true

mstp

dictionary

Multi STP configuration

fwd_delay

integer

Delay in seconds used by STP bridges to transition root and designated ports to forwarding

Range 4-30

hello_time

integer

Interval in seconds between periodic transmissions of configuration messages by designated ports

Range 1-10

max_age

integer

Maximum age in seconds of the information transmitted by the bridge when it is the root bridge

Range 6-40

max_hop

integer

Number of bridges in an MST region that a BPDU can traverse before it is discarded

Range 1-40

mst_instances

list / elements=dictionary

Configuration for MST instances

bridge_priority

integer

The manageable component of the bridge identifier

Value must be a multiple of 4096 in the range of 0-61440

interfaces

list / elements=dictionary

List of STP enabled interfaces

cost

integer

The port’s contribution, when it is the root port, to the root path cost for the bridge

Range 1-200000000

intf_name

string / required

Reference to the STP interface

port_priority

integer

The manageable component of the port identifier, range 0-240

mst_id

integer / required

Value used to identify MST instance, range 0-4094

vlans

list / elements=string

List of VLANs mapped to the MST instance. The value of a list item can be a single VLAN ID or a range of VLAN IDs

separated by ‘-’ or ‘..’; for example 70-100 or 70..100.

mst_name

string

Name of the MST configuration identifier

revision

integer

Revision level of the MST configuration identifier, range 0-65535

pvst

list / elements=dictionary

Per VLAN STP configuration

bridge_priority

integer

The manageable component of the bridge identifier

Value must be a multiple of 4096 in the range of 0-61440

fwd_delay

integer

Delay in seconds used by STP bridges to transition root and designated ports to forwarding

Range 4-30

hello_time

integer

Interval in seconds between periodic transmissions of configuration messages by designated ports

Range 1-10

interfaces

list / elements=dictionary

List of STP enabled interfaces

cost

integer

The port’s contribution, when it is the root port, to the root path cost for the bridge

Range 1-200000000

intf_name

string / required

Reference to the STP interface

port_priority

integer

The manageable component of the port identifier, range 0-240

max_age

integer

Maximum age in seconds of the information transmitted by the bridge when it is the root bridge

Range 6-40

vlan_id

integer / required

VLAN identifier, range 1-4094

rapid_pvst

list / elements=dictionary

Rapid per VLAN STP configuration

bridge_priority

integer

The manageable component of the bridge identifier

Value must be a multiple of 4096 in the range of 0-61440

fwd_delay

integer

Delay in seconds used by STP bridges to transition root and designated ports to forwarding

Range 4-30

hello_time

integer

Interval in seconds between periodic transmissions of configuration messages by designated ports

Range 1-10

interfaces

list / elements=dictionary

List of STP enabled interfaces

cost

integer

The port’s contribution, when it is the root port, to the root path cost for the bridge

Range 1-200000000

intf_name

string / required

Reference to the STP interface

port_priority

integer

The manageable component of the port identifier, range 0-240

max_age

integer

Maximum age in seconds of the information transmitted by the bridge when it is the root bridge

Range 6-40

vlan_id

integer / required

VLAN identifier, range 1-4094

state

string

The state of the configuration after module completion

Choices:

  • "merged" ← (default)

  • "deleted"

  • "replaced"

  • "overridden"

Notes

Note

  • Tested against Enterprise SONiC Distribution by Dell Technologies.

  • Supports check_mode.

Examples

# Using merged
#
# Before State:
# -------------
#
# sonic# show running-configuration spanning-tree
# (No spanning-tree configuration present)

- name: Merge STP configurations
  dellemc.enterprise_sonic.sonic_stp:
    config:
      global:
        enabled_protocol: mst
        loop_guard: true
        bpdu_filter: true
        disabled_vlans:
          - 4-6
        hello_time: 5
        max_age: 10
        fwd_delay: 20
        bridge_priority: 4096
      interfaces:
        - intf_name: Ethernet20
          edge_port: true
          link_type: shared
          guard: loop
          bpdu_guard: true
          bpdu_filter: true
          uplink_fast: true
          shutdown: true
          cost: 20
          port_priority: 30
          stp_enable: true
      mstp:
        mst_name: mst1
        revision: 1
        max_hop: 3
        hello_time: 6
        max_age: 9
        fwd_delay: 12
        mst_instances:
          - mst_id: 1
            bridge_priority: 2048
            vlans:
              - 1
            interfaces:
              - intf_name: Ethernet20
                cost: 60
                port_priority: 65
    state: merged

# After State:
# ------------
#
# sonic# show running-configuration spanning-tree
#  no spanning-tree vlan 4-6
#  spanning-tree mode mst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree forward-time 20
#  spanning-tree hello-time 5
#  spanning-tree max-age 10
#  spanning-tree loopguard default
#  spanning-tree mst hello-time 6
#  spanning-tree mst forward-time 12
#  spanning-tree mst max-age 9
#  spanning-tree mst max-hops 3
#  spanning-tree mst 1 priority 2048
#  !
#  spanning-tree mst configuration
#   name mst1
#   revision 1
#   instance 1 vlan 1
#   activate
#  !
#  interface Ethernet20
#   spanning-tree bpdufilter enable
#   spanning-tree guard loop
#   spanning-tree bpduguard port-shutdown
#   spanning-tree cost 20
#   spanning-tree link-type shared
#   spanning-tree port-priority 30
#   spanning-tree port type edge
#   spanning-tree uplinkfast
#   spanning-tree mst 1 cost 60
#   spanning-tree mst 1 port-priority 65


# Using replaced
#
# Before State:
# -------------
#
# sonic# show running-configuration spanning-tree
#  no spanning-tree vlan 4-6
#  spanning-tree mode mst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree loopguard default
#  spanning-tree mst hello-time 6
#  spanning-tree mst forward-time 12
#  spanning-tree mst max-age 9
#  spanning-tree mst max-hops 3
#  spanning-tree mst 1 priority 2048
#  !
#  spanning-tree mst configuration
#   name mst1
#   revision 1
#   instance 1 vlan 1
#   activate
#  !
#  interface Ethernet20
#   spanning-tree bpdufilter enable
#   spanning-tree guard loop
#   spanning-tree bpduguard port-shutdown
#   spanning-tree cost 20
#   spanning-tree link-type shared
#   spanning-tree port-priority 30
#   spanning-tree port type edge
#   spanning-tree uplinkfast
#   spanning-tree mst 1 cost 60
#   spanning-tree mst 1 port-priority 65

- name: Replace STP configurations
  dellemc.enterprise_sonic.sonic_stp:
    config:
      interfaces:
        - intf_name: Ethernet20
          cost: 25
          port_priority: 35
      mstp:
        mst_name: mst2
        revision: 2
        max_hop: 4
        hello_time: 7
        max_age: 10
        fwd_delay: 13
    state: replaced

# After State:
# ------------
#
# sonic# show running-configuration spanning-tree
#  no spanning-tree vlan 4-6
#  spanning-tree mode mst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree loopguard default
#  spanning-tree mst hello-time 7
#  spanning-tree mst forward-time 13
#  spanning-tree mst max-age 10
#  spanning-tree mst max-hops 4
#  !
#  spanning-tree mst configuration
#   name mst2
#   revision 2
#   activate
#  !
#  interface Ethernet20
#   spanning-tree cost 25
#   spanning-tree port-priority 35


# Using overridden
#
# Before State:
# -------------
#
# sonic# show running-configuration spanning-tree
#  no spanning-tree vlan 4-6
#  spanning-tree mode mst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree loopguard default
#  spanning-tree mst hello-time 7
#  spanning-tree mst forward-time 13
#  spanning-tree mst max-age 10
#  spanning-tree mst max-hops 4
#  !
#  spanning-tree mst configuration
#   name mst2
#   revision 2
#   activate
#  !
#  interface Ethernet20
#   spanning-tree cost 25
#   spanning-tree port-priority 35

- name: Override STP configurations
  dellemc.enterprise_sonic.sonic_stp:
    config:
      global:
        enabled_protocol: pvst
        bpdu_filter: true
        root_guard_timeout: 25
        portfast: true
        hello_time: 5
        max_age: 10
        fwd_delay: 20
        bridge_priority: 4096
      pvst:
        - vlan_id: 1
          hello_time: 4
          max_age: 6
          fwd_delay: 8
          bridge_priority: 4096
          interfaces:
            - intf_name: Ethernet20
              cost: 10
              port_priority: 50
    state: overridden

# After State:
# ------------
#
# sonic# show running-configuration spanning-tree
#  spanning-tree mode pvst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree forward-time 20
#  spanning-tree guard root timeout 25
#  spanning-tree hello-time 5
#  spanning-tree max-age 10
#  spanning-tree priority 4096
#  spanning-tree portfast default
#  spanning-tree vlan 1 hello-time 4
#  spanning-tree vlan 1 forward-time 8
#  spanning-tree vlan 1 max-age 6
# sonic# show running-configuration interface Ethernet 20 | grep spanning-tree
#  spanning-tree vlan 1 cost 10
#  spanning-tree vlan 1 port-priority 50


# Using deleted
#
# Before State:
# -------------
#
# sonic# show running-configuration spanning-tree
#  spanning-tree mode pvst
#  spanning-tree edge-port bpdufilter default
#  spanning-tree forward-time 20
#  spanning-tree guard root timeout 25
#  spanning-tree hello-time 5
#  spanning-tree max-age 10
#  spanning-tree priority 4096
#  spanning-tree portfast default
#  spanning-tree vlan 1 hello-time 4
#  spanning-tree vlan 1 forward-time 8
#  spanning-tree vlan 1 max-age 6
# sonic# show running-configuration interface Ethernet 20 | grep spanning-tree
#  spanning-tree vlan 1 cost 10
#  spanning-tree vlan 1 port-priority 50

- name: Delete STP configurations
  dellemc.enterprise_sonic.sonic_stp:
    config:
      global:
        bpdu_filter: true
        root_guard_timeout: 25
      pvst:
        - vlan_id: 1
          interfaces:
            - intf_name: Ethernet20
    state: deleted

# After State:
# ------------
#
# sonic# show running-configuration spanning-tree
# spanning-tree mode pvst
# spanning-tree forward-time 20
# spanning-tree hello-time 5
# spanning-tree max-age 10
# spanning-tree priority 4096
# spanning-tree portfast default
# spanning-tree vlan 1 hello-time 4
# spanning-tree vlan 1 forward-time 8
# spanning-tree vlan 1 max-age 6
# sonic# show running-configuration interface Ethernet 20 | grep spanning-tree
# (No spanning-tree configuration present)

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

after

list / elements=string

The resulting configuration module invocation.

Returned: when changed

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

after(generated)

list / elements=string

The generated configuration module invocation.

Returned: when check_mode

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

before

list / elements=string

The configuration prior to the module invocation.

Returned: always

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

Sample: ["command 1", "command 2", "command 3"]

Authors

  • Shade Talabi (@stalabi1)