dellemc.enterprise_sonic.sonic_prefix_lists 模块 – 用于 SONiC 的前缀列表配置处理

注意

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

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

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

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

dellemc.enterprise_sonic 2.0.0 中的新功能

概要

  • 此模块为运行 SONiC 的设备上的前缀列表参数提供配置管理。

参数

参数

注释

config

列表 / elements=字典

指定前缀集配置字典的列表

afi

字符串

指定前缀列表条目中地址的地址族

选择

  • "ipv4" ← (默认)

  • "ipv6"

name

字符串 / 必需

前缀集(前缀条目列表)的名称

prefixes

列表 / elements=字典

前缀条目的列表

action

字符串 / 必需

对与此前缀条目匹配的地址采取的操作

选择

  • "permit"

  • "deny"

ge

整数

要匹配的最小前缀长度

le

整数

要匹配的最大前缀长度

prefix

字符串 / 必需

A.B.C.D/LEN 或 A:B::C:D/LEN 格式的 IPv4 或 IPv6 前缀

sequence

整数 / 必需

此前缀条目的优先级(在前缀列表中唯一)

state

字符串

指定要在设备上执行的配置更新类型。

对于“merged”,将指定的属性与现有配置的属性合并。

对于“deleted”,从现有配置中删除指定的属性。

对于“replaced”,将指定的现有配置替换为提供的配置。

对于“overridden”,使用提供的配置覆盖现有配置。

选择

  • "merged" ← (默认)

  • "deleted"

  • "replaced"

  • "overridden"

说明

注意

  • 支持 check_mode

  • 支持 D(diff_mode)。

示例

# Using "merged" state to create initial configuration
#
# Before state:
# -------------
#
# sonic# show running-configuration ip prefix-list
# sonic#
# (No configuration present)
#
# -------------
#
- name: Merge initial prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "1.2.3.4/24"
             action: "permit"
             ge: 26
             le: 30
     state: merged

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ------------
#
# ***************************************************************
# Using "merged" state to update and add configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ------------
#
- name: Merge additional prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 20
             action: "deny"
             prefix: "1.2.3.12/26"
           - sequence: 30
             action: "permit"
             prefix: "7.8.9.0/24"
       - name: pfx6
         afi: "ipv6"
         prefixes:
           - sequence: 25
             action: "permit"
             prefix: "40::300/124"
     state: merged

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ***************************************************************
# Using "deleted" state to remove configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ------------
#
- name: Delete selected prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx1
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "1.2.3.4/24"
             action: "permit"
             ge: 26
             le: 30
           - sequence: 20
             action: "deny"
             prefix: "1.2.3.12/26"
       - name: pfx6
         afi: "ipv6"
         prefixes:
           - sequence: 25
             action: "permit"
             prefix: "40::300/124"
     state: deleted

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ***************************************************************
# Using "overriden" state to override configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30
# ip prefix-list pfx3 seq 20 deny 1.2.3.12/26
# ip prefix-list pfx4 seq 30 permit 7.8.9.0/24
#
# sonic# show running-configuration ipv6 prefix-list
# !
# ipv6 prefix-list pfx6 seq 25 permit 40::300/124
#
# ------------
#
- name: Override prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx2
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "10.20.30.128/24"
             action: "deny"
             ge: 25
             le: 30
     state: overridden

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 deny 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ***************************************************************
# Using "replaced" state to replace configuration
#
# Before state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 deny 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# (no IPv6 prefix-list configuration present)
#
# ------------
#
- name: Replace prefix-list configuration
  dellemc.enterprise_sonic.sonic_prefix_lists:
     config:
       - name: pfx2
         afi: "ipv4"
         prefixes:
           - sequence: 10
             prefix: "10.20.30.128/24"
             action: "permit"
             ge: 25
             le: 30
       - name: pfx3
         afi: "ipv6"
         prefixes:
           - sequence: 20
             action: "deny"
             prefix: "60::70/124"
     state: replaced

# After state:
# ------------
#
# sonic# show running-configuration ip prefix-list
# !
# ip prefix-list pfx2 seq 10 permit 10.20.30.128/24 ge 25 le 30
#
# sonic# show running-configuration ipv6 prefix-list
# sonic#
# !
# ipv6 prefix-list pfx3 seq 20 deny 60::70/124
#

返回值

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

描述

after

列表 / elements=字符串

生成的配置模块调用。

返回: 当更改时

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

after(generated)

列表 / elements=字符串

生成的配置模块调用。

返回:check_mode

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

before

列表 / elements=字符串

模块调用之前的配置。

返回: 始终

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

commands

列表 / elements=字符串

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

返回: 始终

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

diff

列表 / elements=字符串

“before”和“after”(或“after(generated)”)之间的差异。

返回: 当 D(diff_mode) 时

示例: ["差异显示了差异行周围的几行上下文。\n"]

作者

  • Kerry Meyer (@kerry-meyer)