dellemc.enterprise_sonic.sonic_l2_interfaces 模块 – 基于访问或Trunk模式配置接口与VLAN关联

注意

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

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

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

要在剧本中使用它,请指定: dellemc.enterprise_sonic.sonic_l2_interfaces

dellemc.enterprise_sonic 1.0.0 中的新增功能

概要

  • 管理戴尔科技公司提供的企业SONiC发行版的第2层接口属性。

注意

此模块具有相应的 action 插件

参数

参数

注释

config

列表 / 元素=字典

第2层接口配置列表。

access

字典

配置接口的访问模式特性。

vlan

整数

在访问模式下配置指定的VLAN。

name

字符串 / 必填

接口的全名,例如“Eth1/26”。

trunk

字典

配置接口上的Trunk参数。

allowed_vlans

列表 / 元素=字典

指定接口允许的Trunk模式VLAN和VLAN范围列表。

vlan

字符串

配置指定的Trunk模式VLAN或VLAN范围。

state

字符串

配置应保留的状态。

选项

  • "merged" ← (默认)

  • "deleted"

  • "replaced"

  • "overridden"

备注

注意

  • 针对戴尔科技公司提供的企业SONiC发行版进行了测试。

  • 支持 check_mode

示例

# Using deleted
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Eth1/3
#11         Inactive    T  Eth1/3
#12         Inactive    A  Eth1/4
#13         Inactive    T  Eth1/4
#14         Inactive    A  Eth1/5
#15         Inactive    T  Eth1/5
#
- name: Configures switch port of interfaces
  dellemc.enterprise_sonic.sonic_l2_interfaces:
   config:
     - name: Eth1/3
     - name: Eth1/4
   state: deleted
#
# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#11         Inactive
#12         Inactive
#13         Inactive
#14         Inactive    A  Eth1/5
#15         Inactive    T  Eth1/5
#
#
# Using deleted
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Eth1/3
#11         Inactive    T  Eth1/3
#12         Inactive    A  Eth1/4
#13         Inactive    T  Eth1/4
#14         Inactive    A  Eth1/5
#15         Inactive    T  Eth1/5
#
- name: Configures switch port of interfaces
  dellemc.enterprise_sonic.sonic_l2_interfaces:
    config:
    state: deleted
#
# After state:
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#11         Inactive
#12         Inactive
#13         Inactive
#14         Inactive
#15         Inactive
#
#
# Using deleted
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#11         Inactive    T  Ethernet12
#12         Inactive    A  Ethernet12
#13         Inactive    T  Ethernet12
#14         Inactive    T  Ethernet12
#15         Inactive    T  Ethernet12
#16         Inactive    T  Ethernet12

- name: Delete the access vlan and a range of trunk vlans for an interface
  sonic_l2_interfaces:
    config:
      - name: Ethernet12
        access:
          vlan: 12
        trunk:
          allowed_vlans:
             - vlan: 13-16
    state: deleted

# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#11         Inactive    T  Ethernet12
#12         Inactive
#13         Inactive
#14         Inactive
#15         Inactive
#16         Inactive
#
#
#
# Using merged
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#11         Inactive    T  Eth1/7
#12         Inactive    T  Eth1/7
#
- name: Configures an access vlan for an interface
  dellemc.enterprise_sonic.sonic_l2_interfaces:
    config:
     - name: Eth1/3
       access:
         vlan: 10
    state: merged
#
# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Eth1/3
#11         Inactive    T  Eth1/7
#12         Inactive    T  Eth1/7
#
#
# Using merged
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Eth1/3
#12         Inactive
#13         Inactive
#14         Inactive
#15         Inactive
#16         Inactive
#18         Inactive
#
- name: Modify the access vlan, add a range of trunk vlans and a single trunk vlan for an interface
  dellemc.enterprise_sonic.sonic_l2_interfaces:
    config:
     - name: Eth1/3
       access:
         vlan: 12
       trunk:
         allowed_vlans:
            - vlan: 13-16
            - vlan: 18
    state: merged
#
# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#12         Inactive    A  Eth1/3
#13         Inactive    T  Eth1/3
#14         Inactive    T  Eth1/3
#15         Inactive    T  Eth1/3
#16         Inactive    T  Eth1/3
#18         Inactive    T  Eth1/3
#
#
# Using merged
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#11         Inactive
#12         Inactive    A  Eth1/4
#13         Inactive    T  Eth1/4
#14         Inactive    A  Eth1/5
#15         Inactive    T  Eth1/5
#
- name: Configures switch port of interfaces
  dellemc.enterprise_sonic.sonic_l2_interfaces:
    config:
     - name: Eth1/3
       access:
         vlan: 12
       trunk:
         allowed_vlans:
            - vlan: 13
            - vlan: 14
    state: merged
#
# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#11         Inactive
#12         Inactive    A  Eth1/3
#                       A  Eth1/4
#13         Inactive    T  Eth1/3
#                       T  Eth1/4
#14         Inactive    A  Eth1/3
#                       A  Eth1/5
#15         Inactive    T  Eth1/5
#
#
# Using replaced
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Ethernet12
#                       A  Ethernet13
#11         Inactive    T  Ethernet12
#                       T  Ethernet13

- name: Replace access vlan and trunk vlans for specified interfaces
  sonic_l2_interfaces:
    config:
      - name: Ethernet12
        access:
          vlan: 12
        trunk:
          allowed_vlans:
             - vlan: 13-14
      - name: Ethernet14
        access:
          vlan: 10
        trunk:
          allowed_vlans:
             - vlan: 11
             - vlan: 13-14
    state: replaced

# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Ethernet13
#                       A  Ethernet14
#11         Inactive    T  Ethernet13
#                       T  Ethernet14
#12         Inactive    A  Ethernet12
#13         Inactive    T  Ethernet12
#                       T  Ethernet14
#14         Inactive    T  Ethernet12
#                       T  Ethernet14
#
#
# Using overridden
#
# Before state:
# -------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive    A  Ethernet11
#11         Inactive    T  Ethernet11
#12         Inactive    A  Ethernet12
#13         Inactive    T  Ethernet12

- name: Override L2 interfaces configuration in device with provided configuration
  sonic_l2_interfaces:
    config:
      - name: Ethernet13
        access:
          vlan: 12
        trunk:
          allowed_vlans:
             - vlan: 13-14
    state: overridden

# After state:
# ------------
#
#do show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#12         Inactive    A  Ethernet13
#13         Inactive    T  Ethernet13
#14         Inactive    T  Ethernet13
#
#

返回值

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

描述

after

列表 / 元素=字符串

模块调用的结果配置。

返回:发生更改时

示例: ["The configuration returned is always in the same format as the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的配置。

返回:始终返回

示例: ["The configuration returned always in the same format as the parameters above.\n"]

commands

列表 / 元素=字符串

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

返回:始终返回

示例: ["command 1", "command 2", "command 3"]

作者

  • Niraimadaiselvam M(@niraimadaiselvamm)