dellemc.enterprise_sonic.sonic_vlans 模块 – 管理 VLAN 及其参数

注意

此模块是 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_vlans

dellemc.enterprise_sonic 1.0.0 中的新增功能

概要

  • 此模块提供对运行戴尔科技公司 Enterprise SONiC 发行版的设备上的 VLAN 参数的配置管理。

注意

此模块具有相应的 action 插件

参数

参数

注释

config

列表 / 元素=字典

VLAN 选项的字典。

description

字符串

关于 VLAN 的描述。

vlan_id

整数 / 必需

VLAN 的 ID

范围是 1 到 4094

state

字符串

配置应保留的状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

备注

注意

  • 针对戴尔科技公司 Enterprise SONiC 发行版进行了测试。

  • 支持 check_mode

示例

# Using merged

# Before state:
# -------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#30         Inactive
#
#sonic#
#


- name: Merges given VLAN attributes with the device configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
        description: "Internal"
    state: merged

# After state:
# ------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#30         Inactive
#
#sonic#
#
#sonic# show interface Vlan 10
#Description: Internal
#Vlan10 is up
#Mode of IPV4 address assignment: not-set
#Mode of IPV6 address assignment: not-set
#IP MTU 6000 bytes
#sonic#
#

# Using replaced

# Before state:
# -------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#30         Inactive
#
#sonic#

- name: Replace all attributes of specified VLANs with provided configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
    state: replaced

# After state:
# ------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#30         Inactive
#
#sonic#

# Using overridden

# Before state:
# -------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#30         Inactive
#
#sonic#

- name: Override device configuration of all VLANs with provided configuration
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 10
    state: overridden

# After state:
# ------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#
#sonic#

# Using deleted

# Before state:
# -------------
#
#sonic# show interface Vlan 70
#Description: Internal
#Vlan70 is up
#Mode of IPV4 address assignment: not-set
#Mode of IPV6 address assignment: not-set
#IP MTU 6000 bytes

- name: Deletes attributes of the given VLANs
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 70
        description: "Internal"
    state: deleted

# After state:
# ------------
#
#sonic# show interface Vlan 70
#Vlan70 is up
#Mode of IPV4 address assignment: not-set
#Mode of IPV6 address assignment: not-set
#IP MTU 6000 bytes

# Before state:
# -------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#20         Inactive
#
#sonic#

- name: Deletes attributes of the given VLANs
  dellemc.enterprise_sonic.sonic_vlans:
    config:
      - vlan_id: 20
    state: deleted

# After state:
# ------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#
#sonic#


# Using deleted

# Before state:
# -------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#10         Inactive
#20         Inactive
#30         Inactive
#
#sonic#

- name: Deletes all the VLANs on the switch
  dellemc.enterprise_sonic.sonic_vlans:
    config:
    state: deleted

# After state:
# ------------
#
#sonic# show Vlan
#Q: A - Access (Untagged), T - Tagged
#NUM        Status      Q Ports
#
#sonic#

返回值

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

描述

after

列表 / 元素=字符串

模块调用的结果配置。

返回:发生更改时

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

before

列表 / 元素=字符串

模块调用之前的配置。

返回:始终返回

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

commands

列表 / 元素=字符串

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

返回:始终返回

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

作者

  • Mohamed Javeed (@javeedf)