dellemc.enterprise_sonic.sonic_mac 模块 – 管理 SONiC 上的 MAC 配置

注意

此模块是 dellemc.enterprise_sonic 集合(版本 2.5.1)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定:dellemc.enterprise_sonic.sonic_mac

dellemc.enterprise_sonic 2.1.0 中的新增功能

概要

  • 此模块提供运行 SONiC 的设备的 MAC 配置管理

参数

参数

注释

config

列表 / 元素=字典

MAC 配置的列表。

mac

字典

MAC 的配置属性。

aging_time

整数

MAC 条目超时前的不活动时间(秒)。

默认值: 600

dampening_interval

整数

在禁用端口上的 MAC 学习之前,观察 MAC 移动的时间间隔。

默认值: 5

dampening_threshold

整数

在禁用端口上的 MAC 学习之前,每秒允许的 MAC 移动次数。

默认值: 5

mac_table_entries

列表 / 元素=字典

MAC 表条目的配置属性。

interface

字符串

指定 MAC 表条目的接口。

mac_address

字符串 / 必需

动态或静态 MAC 表条目的 MAC 地址。

vlan_id

整数 / 必需

MAC 地址所在的 VLAN 的 ID 号。

vrf_name

字符串

指定 VRF 名称。

默认值: "default"

state

字符串

模块完成后配置的状态

选择

  • "merged" ← (默认)

  • "deleted"

  • "replaced"

  • "overridden"

注释

注意

  • 已针对戴尔科技公司的 Enterprise SONiC Distribution 进行测试。

  • 支持 check_mode

示例

# Using merged
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 5
# MAC Move Dampening Interval  : 5
# sonic# show running-configuration | grep mac
# (No mac configuration pressent)

  - name: Merge MAC configurations
    dellemc.enterprise_sonic.sonic_mac:
    config:
      - vrf_name: 'default'
        mac:
          aging_time: 50
          dampening_interval: 20
          dampening_threshold: 30
          mac_table_entries:
            - mac_address: '00:00:5e:00:53:af'
              vlan_id: 1
              interface: 'Ethernet20'
            - mac_address: '00:33:33:33:33:33'
              vlan_id: 2
              interface: 'Ethernet24'
            - mac_address: '00:00:4e:00:24:af'
              vlan_id: 3
              interface: 'Ethernet28'
    state: merged

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval  : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan1 Ethernet20
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table aging-time 50
#
#
# Using replaced
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval  : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan1 Ethernet20
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table aging-time 50

  - name: Replace MAC configurations
    dellemc.enterprise_sonic.sonic_mac:
    config:
      - vrf_name: 'default'
        mac:
          aging_time: 45
          dampening_interval: 30
          dampening_threshold: 60
          mac_table_entries:
            - mac_address: '00:00:5e:00:53:af'
              vlan_id: 3
              interface: 'Ethernet24'
            - mac_address: '00:44:44:44:44:44'
              vlan_id: 2
              interface: 'Ethernet20'
    state: replaced

# sonic# show mac dampening
# MAC Move Dampening Threshold : 60
# MAC Move Dampening Interval  : 30
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan3 Ethernet24
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table 00:44:44:44:44:44 Vlan2 Ethernet20
# mac address-table aging-time 45
#
#
# Using overridden
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 60
# MAC Move Dampening Interval  : 30
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan3 Ethernet24
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table 00:44:44:44:44:44 Vlan2 Ethernet20
# mac address-table aging-time 45

  - name: Override MAC cofigurations
    dellemc.enterprise_sonic.sonic_mac:
    config:
      - vrf_name: 'default'
        mac:
          aging_time: 10
          dampening_interval: 20
          dampening_threshold: 30
          mac_table_entries:
            - mac_address: '00:11:11:11:11:11'
              vlan_id: 1
              interface: 'Ethernet20'
            - mac_address: '00:22:22:22:22:22'
              vlan_id: 2
              interface: 'Ethernet24'
    state: overridden

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval  : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:11:11:11:11:11 Vlan1 Ethernet20
# mac address-table 00:22:22:22:22:22 Vlan2 Ethernet24
# mac address-table aging-time 10
#
#
# Using deleted
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval  : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:11:11:11:11:11 Vlan1 Ethernet20
# mac address-table 00:22:22:22:22:22 Vlan2 Ethernet24
# mac address-table aging-time 10

  - name: Delete MAC cofigurations
    dellemc.enterprise_sonic.sonic_mac:
    config:
      - vrf_name: 'default'
        mac:
          aging_time: 10
          dampening_interval: 20
          dampening_threshold: 30
          mac_table_entries:
            - mac_address: '00:11:11:11:11:11'
              vlan_id: 1
              interface: 'Ethernet20'
            - mac_address: '00:22:22:22:22:22'
              vlan_id: 2
              interface: 'Ethernet24'
    state: deleted

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 5
# MAC Move Dampening Interval  : 5
# sonic# show running-configuration | grep mac
# (No mac configuration pressent)

返回值

常见的返回值记录在 此处,以下是此模块独有的字段

描述

after

列表 / 元素=字符串

生成的配置模块调用。

已返回:当更改时

示例: ["返回的配置将始终与上面的参数格式相同。\n"]

after(generated)

列表 / 元素=字符串

生成的配置模块调用。

已返回:check_mode

示例: ["返回的配置将始终与上面的参数格式相同。\n"]

before

列表 / 元素=字符串

模块调用之前的配置。

已返回:始终

示例: ["返回的配置将始终与上面的参数格式相同。\n"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

已返回:始终

示例: ["命令1", "命令2", "命令3"]

作者

  • Shade Talabi (@stalabi1)