dellemc.enterprise_sonic.sonic_interfaces 模块 – 配置接口属性,例如以太网 (Eth)、LAG、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_interfaces

dellemc.enterprise_sonic 1.0.0 中的新增功能

概要

  • 配置接口属性,例如 MTU、管理状态等等,适用于以太网 (Eth)、LAG、VLAN 和环回接口。(如果环回接口不存在,则创建它。)

注意

此模块具有相应的 action 插件

参数

参数

注释

config

列表 / 元素=字典

接口配置列表。

advertised_speed

列表 / 元素=字符串

接口的通告速度。

仅适用于以太网接口。

支持的速度取决于交换机的类型。

速度可以是 10、100、1000、2500、5000、10000、20000、25000、40000、50000、100000 或 400000。

auto_negotiate

布尔值

与对等接口自动协商传输参数。

仅适用于以太网接口。

选项

  • false

  • true

description

字符串

接口描述。

enabled

布尔值

接口的管理状态。

选项

  • false

  • true

fec

字符串

接口 FEC(前向纠错)。

仅适用于以太网接口。

选项

  • "FEC_RS"

  • "FEC_FC"

  • "FEC_DISABLED"

  • "FEC_DEFAULT"

  • "FEC_AUTO"

mtu

整数

接口的 MTU。

不适用于环回接口。

name

字符串 / 必填

接口名称,例如“Eth1/15”。

speed

字符串

接口速度。

仅适用于以太网接口。

支持的速度取决于交换机的类型。

选项

  • "SPEED_10MB"

  • "SPEED_100MB"

  • "SPEED_1GB"

  • "SPEED_2500MB"

  • "SPEED_5GB"

  • "SPEED_10GB"

  • "SPEED_20GB"

  • "SPEED_25GB"

  • "SPEED_40GB"

  • "SPEED_50GB"

  • "SPEED_100GB"

  • "SPEED_400GB"

state

字符串

配置应保留的状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

注释

注意

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

  • 支持 check_mode

示例

# Using deleted
#
# Before state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           Ethernet-8          down                            100000       9100
#Ethernet12          Ethernet-12         down                on          -            5000
#Ethernet16          -                   down                            40000        9100
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# fec AUTO
# shutdown
#
- name: Configure interfaces
  sonic_interfaces:
    config:
      - name: Ethernet8
      - name: Ethernet12
      - name: Ethernet16
    state: deleted
#
# After state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   up                              100000       9100
#Ethernet12          -                   up                              100000       9100
#Ethernet16          -                   up                              100000       9100
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# shutdown
#
# Using deleted
#
# Before state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   down                            100000       9100
#Ethernet12          -                   down                            1000         9100
#Ethernet16          -                   down                            100000       9100
#
- name: Configure interfaces
  sonic_interfaces:
    config:

    state: deleted
#
# After state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   up                              100000       9100
#Ethernet12          -                   up                              100000       9100
#Ethernet16          -                   up                              100000       9100
#
#
#
# Using merged
#
# Before state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   down                            100000       9100
#Ethernet12          -                   down                            100000       9100
#Ethernet16          -                   down                            100000       9100
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# shutdown
#
- name: Configure interfaces
  sonic_interfaces:
    config:
      - name: Ethernet8
        fec: FEC_AUTO
      - name: Ethernet12
        description: 'Ethernet Twelve'
        auto_negotiate: True
      - name: Ethernet16
        description: 'Ethernet Sixteen'
        enabled: True
        mtu: 3500
        speed: SPEED_40GB
    state: merged
#
# After state:
# ------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   down                            100000       9100
#Ethernet12          Ethernet Twelve     down                on          100000       9100
#Ethernet16          Ethernet Sixteen    up                              40000        3500
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# fec AUTO
# shutdown
#
# Using overridden
#
# Before state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           E0                  up                              100000       9100
#Ethernet4           E4                  up                              100000       9100
#Ethernet8           E8                  down                            100000       9100
#Ethernet12          -                   down                            1000         9100
#Ethernet16          -                   down                            100000       9100
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# shutdown
#
- name: Configure interfaces
  sonic_interfaces:
    config:
      - name: Ethernet8
        fec: FEC_AUTO
      - name: Ethernet12
        description: 'Ethernet Twelve'
        mtu: 3500
        enabled: True
        auto_negotiate: True
      - name: Ethernet16
        description: 'Ethernet Sixteen'
        mtu: 3000
        enabled: False
        speed: SPEED_40GB
    state: overridden
#
# After state:
# ------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   down                            100000       9100
#Ethernet4           -                   down                            100000       9100
#Ethernet8           -                   down                            100000       9100
#Ethernet12          Ethernet Twelve     up                  on          100000       3500
#Ethernet16          Ethernet Sixteen    down                            40000        3000
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed 100000
# fec AUTO
# no shutdown
#
# Using replaced
#
# Before state:
# -------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   down               on           100000       9100
#Ethernet12          -                   down                            1000         9100
#Ethernet16          -                   down                            100000       9100
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed auto 40000
# shutdown
#
- name: Configure interfaces
  sonic_interfaces:
    config:
      - name: Ethernet8
        auto_negotiate: True
        advertised_speed:
          - "100000"
      - name: Ethernet12
        description: 'Ethernet Twelve'
        mtu: 3500
        enabled: True
        auto_negotiate: True
      - name: Ethernet16
        description: 'Ethernet Sixteen'
        mtu: 3000
        enabled: False
        speed: SPEED_40GB
    state: replaced
#
# After state:
# ------------
#
# show interface status | no-more
#------------------------------------------------------------------------------------------
#Name                Description         Admin     Oper      AutoNeg     Speed        MTU
#------------------------------------------------------------------------------------------
#Ethernet0           -                   up                              100000       9100
#Ethernet4           -                   up                              100000       9100
#Ethernet8           -                   down                on          100000       9100
#Ethernet12          Ethernet Twelve     up                  on          100000       3500
#Ethernet16          Ethernet Sixteen    down                            40000        3000
#
# show running-configuration interface Ethernet 8
#!
#interface Ethernet8
# mtu 9100
# speed auto 100000
# fec AUTO
# shutdown
#

返回值

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

描述

after

列表 / 元素=字符串

模块调用后的结果配置。

返回:发生更改时

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

before

列表 / 元素=字符串

模块调用之前的配置。

返回:始终返回

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

commands

列表 / 元素=字符串

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

返回:始终返回

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

作者

  • Niraimadaiselvam M (@niraimadaiselvamm)