dellemc.enterprise_sonic.sonic_l3_interfaces 模块 – 配置接口(如 Eth、LAG、VLAN 和环回)上的 IPv4 和 IPv6 参数

注意

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

dellemc.enterprise_sonic 1.0.0 中的新增功能

概要

  • 在运行 Dell Technologies 的 Enterprise SONiC 发行版的设备上配置第 3 层接口设置。此模块提供对运行 Enterprise SONiC 的设备的以太网接口上的 IPv4 和 IPv6 参数的配置管理。

注意

此模块具有相应的 操作插件

参数

参数

注释

config

list / elements=dictionary

l3_interfaces 配置的列表。

ipv4

dictionary

为名称选项中提到的第 3 层接口设置的 IPv4 配置。

addresses

list / elements=dictionary

要设置的 IPv4 地址的列表。

address

string

要设置的 IPv4 地址,格式为 <ipv4 地址>/<掩码>,例如,192.0.2.1/24。

secondary

boolean

ip 地址的辅助标志。

选项

  • false ←(默认)

  • true

anycast_addresses

list / elements=string

为任播设置的 IPv4 地址列表。

ipv6

dictionary

为名称选项中提到的第 3 层接口设置的 IPv6 配置。

addresses

list / elements=dictionary

要设置的 IPv6 地址的列表。

address

string

要设置的 IPv6 地址,格式为 <ipv6 地址>/<掩码>,例如,2001:db8:2201:1::1/64。

eui64

boolean

在 dellemc.enterprise_sonic 2.5.0 中添加

指示是否为 eui64 地址的标志

选项

  • false ←(默认)

  • true

autoconf

boolean

在 dellemc.enterprise_sonic 2.5.0 中添加

自动配置标志

选项

  • false

  • true

dad

string

在 dellemc.enterprise_sonic 2.5.0 中添加

IPv6 nd dad 相关配置。

选项

  • "ENABLE"

  • "DISABLE"

  • "DISABLE_IPV6_ON_FAILURE"

enabled

boolean

ipv6 的启用标志。

选项

  • false

  • true

name

string / required

接口的全名,例如,Eth1/3。

state

string

模块完成后配置的状态。

选项

  • "merged" ←(默认)

  • "deleted"

  • "replaced"

  • "overridden"

备注

注意

  • 针对 Dell Technologies 的 Enterprise SONiC 发行版进行了测试。

  • 支持 check_mode

示例

# Using deleted
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 address 85::/64 eui-64
# ipv6 enable
# ipv6 address autoconfig
# ipv6 nd dad enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ip address 92.1.1.1/16 secondary
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#interface Vlan501
# ip anycast-address 11.12.13.14/12
# ip anycast-address 1.2.3.4/22
#!
#
#
- name: delete l3 interface attributes
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
      - name: Ethernet20
        ipv4:
          addresses:
            - address: 83.1.1.1/16
            - address: 84.1.1.1/16
        ipv6:
          addresses:
            - address: 85::/64
      - name: Ethernet24
        ipv6:
          enabled: true
          addresses:
            - address: 91::1/16
      - name: Vlan501
        ipv4:
          anycast_addresses:
            - 11.12.13.14/12
    state: deleted
#
# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 enable
# ipv6 address autoconfig
# ipv6 nd dad enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ip address 92.1.1.1/16 secondary
# ipv6 address 90::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#interface Vlan501
# ip anycast-address 1.2.3.4/22
#!
#
# Using deleted
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 address 85::/64 eui-64
# ipv6 enable
# ipv6 address autoconfig
# ipv6 nd dad enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#interface Vlan501
# ip anycast-address 11.12.13.14/12
# ip anycast-address 1.2.3.4/22
#!
#
#
- name: delete all l3 interface
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
    state: deleted
#
# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
#!
#interface Vlan501
#!
#
# Using merged
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
#!
#interface Vlan501
# ip anycast-address 1.2.3.4/22
#!
#
- name: Add l3 interface configurations
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
      - name: Ethernet20
        ipv4:
          addresses:
            - address: 83.1.1.1/16
            - address: 84.1.1.1/16
              secondary: True
        ipv6:
          enabled: true
          dad: ENABLE
          autoconf: true
          addresses:
            - address: 83::1/16
            - address: 84::1/16
            - address: 85::/64
              eui64: True
      - name: Ethernet24
        ipv4:
          addresses:
            - address: 91.1.1.1/16
        ipv6:
          addresses:
            - address: 90::1/16
            - address: 91::1/16
            - address: 92::1/16
            - address: 93::1/16
      - name: Vlan501
        ipv4:
          anycast_addresses:
            - 11.12.13.14/12
    state: merged
#
# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 address 85::/64 eui-64
# ipv6 enable
# ipv6 address autoconfig
# ipv6 nd dad enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#interface Vlan501
# ip anycast-address 1.2.3.4/22
# ip anycast-address 11.12.13.14/12
#!
#
# Using replaced
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#
- name: Replace l3 interface
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
      - name: Ethernet20
        ipv4:
          - address: 81.1.1.1/16
    state: replaced

# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 81.1.1.1/16
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#
# Using replaced
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
- name: Replace l3 interface
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
      - name: Ethernet20
    state: replaced

# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#
# Using overridden
#
# Before state:
# -------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
# ip address 83.1.1.1/16
# ip address 84.1.1.1/16 secondary
# ipv6 address 83::1/16
# ipv6 address 84::1/16
# ipv6 address 85::/64 eui-64
# ipv6 enable
# ipv6 address autoconfig
# ipv6 nd dad enable
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 91.1.1.1/16
# ipv6 address 90::1/16
# ipv6 address 91::1/16
# ipv6 address 92::1/16
# ipv6 address 93::1/16
#!
#
- name: Override l3 interface
  dellemc.enterprise_sonic.sonic_l3_interfaces:
    config:
      - name: Ethernet24
        ipv4:
          - address: 81.1.1.1/16
      - name: Vlan100
        ipv4:
          anycast_addresses:
            - 83.1.1.1/24
            - 85.1.1.12/24
    state: overridden

# After state:
# ------------
#
#rno-dctor-1ar01c01sw02# show running-configuration interface
#!
#interface Ethernet20
# mtu 9100
# speed 100000
# shutdown
#!
#interface Ethernet24
# mtu 9100
# speed 100000
# shutdown
# ip address 81.1.1.1/16
#!
#interface Vlan100
# ip anycast-address 83.1.1.1/24
# ip anycast-address 85.1.1.12/24
#!

返回值

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

描述

after

list / elements=string

生成的配置模块调用。

返回值: 当更改时

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

after(generated)

list / elements=string

生成的配置模块调用。

返回值:check_mode

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

before

list / elements=string

模块调用之前的配置。

返回值: 始终

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

commands

list / elements=string

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

返回值: 始终

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

作者

  • Kumaraguru Narayanan (@nkumaraguru)