dellemc.enterprise_sonic.sonic_mirroring module – Manage port mirroring configuration on SONiC.

Note

This module is part of the dellemc.enterprise_sonic collection (version 3.2.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_mirroring.

New in dellemc.enterprise_sonic 3.1.0

Synopsis

  • This module provides configuration management for port mirroring on devices running SONiC.

Parameters

Parameter

Comments

config

dictionary

Specifies port mirroring configuration.

erspan

list / elements=dictionary

ERSPAN mirroring sessions.

direction

string

Mirror session direction.

Choices:

  • "rx"

  • "tx"

  • "both"

dscp

integer

ERSPAN destination DSCP.

The range of values is from 0 to 63.

dst_ip

string

ERSPAN destination IP address.

gre

string

ERSPAN destination GRE type.

A hexadecimal string of the form 0xabcd.

name

string / required

ERSPAN mirroring session name.

queue

integer

ERSPAN destination queue number.

The range of values is from 0 to 63.

Only queue 0 is supported.

source

string

Mirror session source interface.

It may be an Ethernet interface or a PortChannel interface.

src_ip

string

ERSPAN source IP address.

ttl

integer

ERSPAN destination TTL

The range of values is from 0 to 63.

span

list / elements=dictionary

SPAN mirroring sessions.

direction

string

Mirror session direction.

Choices:

  • "rx"

  • "tx"

  • "both"

dst_port

string

Mirror session destination interface.

It may be CPU or an Ethernet interface.

name

string / required

SPAN mirroring session name.

source

string

Mirror session source interface.

It may be an Ethernet interface or a PortChannel interface.

state

string

Specifies the operation to be performed on the mirroring configured on the device.

In case of merged, the input configuration will be merged with the existing configuration on the device.

In case of deleted, the input configuration will be removed from the device.

In case of overridden, all existing mirroring configuration will be deleted and the specified input configuration will be added.

In case of replaced, the existing mirroring configuration on the device will be replaced by the new specified configuration for each affected mirroring session.

Choices:

  • "merged" ← (default)

  • "deleted"

  • "replaced"

  • "overridden"

Notes

Note

  • Tested against Enterprise SONiC Distribution by Dell Technologies.

  • Supports check_mode.

Examples

# Using "deleted" state
#
# Before state:
# -------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-2                   inactive   200.22.22.22     100.11.11.11                          0                   Ethernet28       both
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both
# dell-3                   active     CPU

- name: Delete mirroring configuration
  dellemc.enterprise_sonic.sonic_mirroring:
    config:
      span:
        - name: dell-3
      erspan:
        - name: dell-2
    state: deleted

# After state:
# ------------
#
# sonic# show mirror-session
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both


# Using "merged" state
#
# Before state:
# -------------
#
# sonic# show mirror-session
# No sessions configured

- name: Merge mirroring configuration
  dellemc.enterprise_sonic.sonic_mirroring:
    config:
      span:
        - name: dell-1
          dst_port: CPU
          source: Ethernet24
          direction: both
      erspan:
        - name: dell-2
          dst_ip: 100.11.11.11
          src_ip: 200.22.22.22
          source: Ethernet28
          direction: both
          queue: 0
    state: merged

# After state:
# ------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-2                   inactive   200.22.22.22     100.11.11.11                          0                   Ethernet28       both
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both


# Using "merged" state
#
# Before state:
# -------------
#
# sonic# show mirror-session
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both

- name: Modify existing mirroring configuration
  dellemc.enterprise_sonic.sonic_mirroring:
    config:
      span:
        - name: dell-1
          dst_port: Ethernet32
          source: Ethernet4
          direction: rx

# After state:
# ------------
#
# sonic# show mirror-session
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     Ethernet32       Ethernet4        rx


# Using "replaced" state
#
# Before state:
# -------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-2                   inactive   200.22.22.22     100.11.11.11                          0                   Ethernet28       both
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both
# dell-3                   active     CPU

- name: Replace mirroring configuration
  dellemc.enterprise_sonic.sonic_mirroring:
    config:
      erspan:
        - name: dell-2
          dst_ip: 32.22.22.12
          src_ip: 31.21.21.12
          source: Ethernet28
          dscp: 6
          gre: "0x6689"
          ttl: 9
          queue: 0
          direction: rx
        - name: dell-3
          dst_ip: 22.22.22.12
          src_ip: 21.21.21.12
          source: Ethernet28
          direction: rx
      span:
        - name: dell-1
          dst_port: Ethernet4
          source: Ethernet24
          direction: tx
    state: replaced

# After state:
# ------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-2                   inactive   32.22.22.22      31.11.11.11      0x6689 6      9      0                   Ethernet28       rx
# dell-3                   inactive   21.21.21.12      22.22.22.12                                               Ethernet28       rx
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     Ethertnet4       Ethernet24       tx


# Using "overridden" state
#
# Before state:
# -------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-2                   inactive   200.22.22.22     100.11.11.11                          0                   Ethernet28       both
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-1                   active     CPU              Ethernet24       both
# dell-3                   active     CPU

- name: Override mirroring configuration
  dellemc.enterprise_sonic.sonic_mirroring:
    config:
      erspan:
        - name: dell-2
          dst_ip: 32.22.22.12
          src_ip: 31.21.21.12
          source: Ethernet28
          gre: "0x6689"
          dscp: 6
          ttl: 9
          queue: 0
          direction: rx
        - name: dell-1
          dst_ip: 22.22.22.12
          src_ip: 21.21.21.12
          source: Ethernet28
          direction: rx
      span:
        - name: dell-6
          dst_port: CPU
          source: Ethernet24
          direction: tx
    state: overridden

# After state:
# ------------
#
# sonic# show mirror-session
# ERSPAN Sessions
# -----------------------------------------------------------------------------------------------------------------------------------------
# Name                     Status     SRC-IP           DST-IP           GRE    DSCP   TTL    Queue    Policer    SRC-Port         Direction
# -----------------------------------------------------------------------------------------------------------------------------------------
# dell-1                   inactive   21.21.21.12      22.22.22.12                                               Ethernet28       rx
# dell-2                   inactive   31.21.21.12      32.22.22.12      0x6689 6      9      0                   Ethernet28       rx
# SPAN Sessions
# -------------------------------------------------------------------------------
# Name                     Status     DST-Port         SRC-Port         Direction
# -------------------------------------------------------------------------------
# dell-6                   active     Ethertnet4       Ethernet24       tx

Return Values

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

Key

Description

after

dictionary

The configuration resulting from module invocation.

Returned: when changed

after(generated)

dictionary

The configuration that would result from non-check-mode module invocation.

Returned: when check_mode

before

dictionary

The configuration prior to the module invocation.

Returned: always

commands

list / elements=string

The set of commands pushed to the remote device. In check_mode the needed commands are displayed, but not pushed to the device.

Returned: always

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

Authors

    1. Zhang (@mingjunzhang2019)