cisco.ios.ios_prefix_lists 模块 – 用于配置前缀列表的资源模块。

注意

此模块是 cisco.ios 集合(版本 9.0.3)的一部分。

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

要安装它,请使用:ansible-galaxy collection install cisco.ios

要在 playbook 中使用它,请指定:cisco.ios.ios_prefix_lists

cisco.ios 2.2.0 版本新增

概要

  • 此模块配置和管理 Cisco IOS 上前缀列表的属性。

参数

参数

注释

config

列表 / elements=字典

前缀列表的配置列表。

afi

字符串

前缀列表的地址族指示符 (AFI)。

选择

  • "ipv4"

  • "ipv6"

prefix_lists

列表 / elements=字典

前缀列表的列表。

description

字符串

前缀列表的特定描述

entries

列表 / elements=字典

前缀列表支持的参数。

action

字符串

指定要拒绝或转发的数据包

选择

  • "deny"

  • "permit"

description

字符串

前缀列表的特定描述

条目级别的 Description 参数已弃用

前缀列表级别引入了新的 Description,请使用前缀列表级别定义的 Description 参数,而不是条目级别的 Description 参数,因为在此级别 description 选项将在未来的版本中删除。

ge

整数

要匹配的最小前缀长度

le

整数

要匹配的最大前缀长度

prefix

字符串

IPv4 前缀 <网络>/<长度>,例如 A.B.C.D/nn

IPv6 前缀 <网络>/<长度>,例如 X:X:X:X::X/<0-128>

sequence

整数

条目的序列号

name

字符串

前缀列表的名称

running_config

字符串

此选项仅与状态 *parsed* 一起使用。

此选项的值应该是通过执行命令 sh bgp 从 IOS 设备收到的输出。

状态 *parsed* 从 running_config 选项读取配置,并根据资源模块的参数规范将其转换为 Ansible 结构化数据,然后该值在结果中的 *parsed* 键内返回。

state

字符串

配置应保留的状态

状态 *merged* 是默认状态,它合并了期望配置和现有配置,但对于前缀列表模块,由于 IOS 平台不允许在预先存在的前缀列表上更新前缀列表,因此前缀列表资源模块也会针对相应的情况报错,并且只允许在合并状态下添加新序列的新前缀列表。

状态 *rendered*、*gathered* 和 *parsed* 不会对设备执行任何更改。

状态 *rendered* 会将 config 选项中的配置转换为平台特定的 CLI 命令,这些命令将返回在结果中的 *rendered* 键中。对于状态 *rendered*,不需要与远程主机的活动连接。

状态 *gathered* 将从设备获取正在运行的配置,并根据资源模块的参数规范将其转换为结构化数据,并且该值在结果中的 *gathered* 键内返回。

状态 *parsed* 从 running_config 选项读取配置,并根据资源模块的参数将其转换为 JSON 格式,并且该值在结果中的 *parsed* 键内返回。running_config 选项的值应与在设备上执行的命令 *sh running-config | section ^ip prefix-list|^ipv6 prefix-list* 的输出格式相同。对于状态 *parsed*,不需要与远程主机的活动连接。

选择

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "parsed"

  • "rendered"

注释

注意

示例

# Using deleted by Name

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Delete provided Prefix lists config by Prefix name
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: 10
          - name: test_prefix
    state: deleted

# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - description: this is test description
#     entries:
#     - action: deny
#       le: 15
#       prefix: 1.0.0.0/8
#       sequence: 5
#     - action: deny
#       ge: 10
#       prefix: 35.0.0.0/8
#       sequence: 10
#     - action: deny
#       ge: 15
#       prefix: 12.0.0.0/8
#       sequence: 15
#     - action: deny
#       ge: 20
#       le: 21
#       prefix: 14.0.0.0/8
#       sequence: 20
#     name: '10'
#   - description: this is test
#     entries:
#     - action: deny
#       ge: 15
#       prefix: 12.0.0.0/8
#       sequence: 50
#     name: test
#   - description: this is for prefix-list
#     entries:
#     - action: deny
#       ge: 10
#       le: 15
#       prefix: 35.0.0.0/8
#       sequence: 5
#     - action: deny
#       ge: 20
#       prefix: 35.0.0.0/8
#       sequence: 10
#     name: test_prefix
# - afi: ipv6
#   prefix_lists:
#   - description: this is ipv6 prefix-list
#     entries:
#     - action: deny
#       ge: 80
#       prefix: 2001:DB8:0:4::/64
#       sequence: 10
#     name: test_ipv6
# commands:
# - no ip prefix-list 10
# - no ip prefix-list test_prefix
# after:
# - afi: ipv4
#   prefix_lists:
#   - description: this is test
#     entries:
#     - action: deny
#       ge: 15
#       prefix: 12.0.0.0/8
#       sequence: 50
#     name: test
# - afi: ipv6
#   prefix_lists:
#   - description: this is ipv6 prefix-list
#     entries:
#     - action: deny
#       ge: 80
#       prefix: 2001:DB8:0:4::/64
#       sequence: 10
#    name: test_ipv6


# After state:
# ------------
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

# Using deleted by AFI

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Delete provided Prefix lists config by AFI
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
    state: deleted

# Task Output
# -------------
# before:
# - afi: ipv4
#   prefix_lists:
#   - description: this is test description
#     entries:
#     - action: deny
#       le: 15
#       prefix: 1.0.0.0/8
#       sequence: 5
#     - action: deny
#       ge: 10
#       prefix: 35.0.0.0/8
#       sequence: 10
#     - action: deny
#       ge: 15
#       prefix: 12.0.0.0/8
#       sequence: 15
#     - action: deny
#       ge: 20
#       le: 21
#       prefix: 14.0.0.0/8
#       sequence: 20
#     name: '10'
#   - description: this is test
#     entries:
#     - action: deny
#       ge: 15
#       prefix: 12.0.0.0/8
#       sequence: 50
#     name: test
#   - description: this is for prefix-list
#     entries:
#     - action: deny
#       ge: 10
#       le: 15
#       prefix: 35.0.0.0/8
#       sequence: 5
#     - action: deny
#       ge: 20
#       prefix: 35.0.0.0/8
#       sequence: 10
#     name: test_prefix
# - afi: ipv6
#   prefix_lists:
#   - description: this is ipv6 prefix-list
#     entries:
#     - action: deny
#       ge: 80
#       prefix: 2001:DB8:0:4::/64
#       sequence: 10
#     name: test_ipv6
# commands:
#   - "no ip prefix-list test",
#   - "no ip prefix-list 10",
#   - "no ip prefix-list test_prefix"
# after:
# - afi: ipv6
#   prefix_lists:
#   - description: this is ipv6 prefix-list
#     entries:
#     - action: deny
#       ge: 80
#       prefix: 2001:DB8:0:4::/64
#       sequence: 10
#    name: test_ipv6


# After state:
# -------------
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

# Using deleted without any config passed (NOTE: This will delete all Prefix lists configuration from device)

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Delete all Prefix lists config
  cisco.ios.ios_prefix_lists:
    state: deleted

# Commands Fired:
# ---------------
#
#  "commands": [
#         "no ip prefix-list test",
#         "no ip prefix-list 10",
#         "no ip prefix-list test_prefix",
#         "no ipv6 prefix-list test_ipv6"
#     ]

# After state:
# -------------
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# router-ios#

# Using merged

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ipv6 prefix-list test_ipv6 description this is ipv6
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Merge provided Prefix lists configuration
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv6
        prefix_lists:
          - name: test_ipv6
            description: this is ipv6 merge test
            entries:
              - action: deny
                prefix: 2001:DB8:0:4::/64
                ge: 80
                le: 100
                sequence: 10
    state: merged

# After state:
# -------------
#
# Play Execution fails, with error:
# Cannot update existing sequence 10 of Prefix Lists test_ipv6 with state merged.
# Please use state replaced or overridden.

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ipv6 prefix-list test_ipv6 description this is ipv6
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Merge provided Prefix lists configuration
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: 10
            description: this is new merge test
            entries:
              - action: deny
                prefix: 1.0.0.0/8
                le: 15
                sequence: 5
              - action: deny
                prefix: 35.0.0.0/8
                ge: 10
                sequence: 10
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 15
              - action: deny
                prefix: 14.0.0.0/8
                ge: 20
                le: 21
                sequence: 20
          - name: test
            description: this is merge test
            entries:
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 50
          - name: test_prefix
            description: this is for prefix-list
            entries:
              - action: deny
                prefix: 35.0.0.0/8
                ge: 10
                le: 15
                sequence: 5
              - action: deny
                prefix: 35.0.0.0/8
                ge: 20
                sequence: 10
      - afi: ipv6
        prefix_lists:
          - name: test_ipv6
            description: this is ipv6 merge test
            entries:
              - action: deny
                prefix: 2001:DB8:0:4::/64
                ge: 80
                le: 100
                sequence: 20
    state: merged

#  Commands Fired:
#  ---------------
#
#   "commands": [
#         "ip prefix-list test description this is merge test",
#         "ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15",
#         "ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15",
#         "ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10",
#         "ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15",
#         "ip prefix-list 10 description this is new merge test",
#         "ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21",
#         "ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20",
#         "ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15",
#         "ip prefix-list test_prefix description this is for prefix-list",
#         "ipv6 prefix-list test_ipv6 seq 20 deny 2001:DB8:0:4::/64 ge 80 le 100",
#         "ipv6 prefix-list test_ipv6 description this is ipv6 merge test"
#     ]

# After state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is new merge test
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is merge test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 merge test
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100

# Using overridden

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Override provided Prefix lists configuration
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: 10
            description: this is override test
            entries:
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 15
              - action: deny
                prefix: 14.0.0.0/8
                ge: 20
                le: 21
                sequence: 20
          - name: test_override
            description: this is override test
            entries:
              - action: deny
                prefix: 35.0.0.0/8
                ge: 20
                sequence: 10
      - afi: ipv6
        prefix_lists:
          - name: test_ipv6
            description: this is ipv6 override test
            entries:
              - action: deny
                prefix: 2001:DB8:0:4::/64
                ge: 80
                le: 100
                sequence: 10
    state: overridden

# Commands Fired:
# ---------------
#
#  "commands": [
#         "no ip prefix-list test",
#         "no ip prefix-list test_prefix",
#         "ip prefix-list 10 description this is override test",
#         "no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10",
#         "no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15",
#         "ip prefix-list test_override seq 10 deny 35.0.0.0/8 ge 20",
#         "ip prefix-list test_override description this is override test",
#         "no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80",
#         "ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100",
#         "ipv6 prefix-list test_ipv6 description this is ipv6 override test"
#     ]

# After state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is override test
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test_override description this is override test
# ip prefix-list test_override seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 override test
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100

# Using replaced

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Replaced provided Prefix lists configuration
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: 10
            description: this is replace test
            entries:
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 15
              - action: deny
                prefix: 14.0.0.0/8
                ge: 20
                le: 21
                sequence: 20
          - name: test_replace
            description: this is replace test
            entries:
              - action: deny
                prefix: 35.0.0.0/8
                ge: 20
                sequence: 10
      - afi: ipv6
        prefix_lists:
          - name: test_ipv6
            description: this is ipv6 replace test
            entries:
              - action: deny
                prefix: 2001:DB8:0:4::/64
                ge: 80
                le: 100
                sequence: 10
    state: replaced

# Commands Fired:
# ---------------
#  "commands": [
#         "ip prefix-list 10 description this is replace test",
#         "no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10",
#         "no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15",
#         "ip prefix-list test_replace seq 10 deny 35.0.0.0/8 ge 20",
#         "ip prefix-list test_replace description this is replace test",
#         "no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80",
#         "ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100",
#         "ipv6 prefix-list test_ipv6 description this is ipv6 replace test"
#     ]

# After state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is replace test
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ip prefix-list test_replace description this is replace test
# ip prefix-list test_replace seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 replace test
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100

# Using Gathered

# Before state:
# -------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Gather Prefix lists provided configurations
  cisco.ios.ios_prefix_lists:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
# "gathered": [
#         {
#             "afi": "ipv4",
#             "prefix_lists": [
#                 {
#                     "description": "this is test description"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "le": 15,
#                             "prefix": "1.0.0.0/8",
#                             "sequence": 5
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 10,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 10
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 15,
#                             "prefix": "12.0.0.0/8",
#                             "sequence": 15
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 20,
#                             "le": 21,
#                             "prefix": "14.0.0.0/8",
#                             "sequence": 20
#                         }
#                     ],
#                     "name": "10"
#                 },
#                 {
#                     "description": "this is test"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 15,
#                             "prefix": "12.0.0.0/8",
#                             "sequence": 50
#                         }
#                     ],
#                     "name": "test"
#                 },
#                 {
#                     "description": "this is for prefix-list"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 10,
#                             "le": 15,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 5
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 20,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 10
#                         }
#                     ],
#                     "name": "test_prefix"
#                 }
#             ]
#         },
#         {
#             "afi": "ipv6",
#             "prefix_lists": [
#                 {
#                     "description": "this is ipv6 prefix-list"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 80,
#                             "prefix": "2001:DB8:0:4::/64",
#                             "sequence": 10
#                         }
#                     ],
#                     "name": "test_ipv6"
#                 }
#             ]
#         }
#     ]

# After state:
# ------------
#
# router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

# Using Rendered

- name: Render the commands for provided  configuration
  cisco.ios.ios_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: 10
            description: this is new merge test
            entries:
              - action: deny
                prefix: 1.0.0.0/8
                le: 15
                sequence: 5
              - action: deny
                prefix: 35.0.0.0/8
                ge: 10
                sequence: 10
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 15
              - action: deny
                prefix: 14.0.0.0/8
                ge: 20
                le: 21
                sequence: 20
          - name: test
            description: this is merge test
            entries:
              - action: deny
                prefix: 12.0.0.0/8
                ge: 15
                sequence: 50
          - name: test_prefix
            description: this is for prefix-list
            entries:
              - action: deny
                prefix: 35.0.0.0/8
                ge: 10
                le: 15
                sequence: 5
              - action: deny
                prefix: 35.0.0.0/8
                ge: 20
                sequence: 10
      - afi: ipv6
        prefix_lists:
          - name: test_ipv6
            description: this is ipv6 merge test
            entries:
              - action: deny
                prefix: 2001:DB8:0:4::/64
                ge: 80
                le: 100
                sequence: 10
    state: rendered

# Module Execution Result:
# ------------------------
#
#  "rendered": [
#         "ip prefix-list test description this is test",
#         "ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15",
#         "ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15",
#         "ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10",
#         "ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15",
#         "ip prefix-list 10 description this is test description",
#         "ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21",
#         "ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20",
#         "ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15",
#         "ip prefix-list test_prefix description this is for prefix-list",
#         "ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 l2 100",
#         "ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list"
#     ]

# Using Parsed

# File: parsed.cfg
# ----------------
#
# ip prefix-list 10 description this is test description
# ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
# ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
# ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
# ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
# ip prefix-list test description this is test
# ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
# ip prefix-list test_prefix description this is for prefix-list
# ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
# ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
# ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
# ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80

- name: Parse the provided configuration with the existing running configuration
  cisco.ios.ios_prefix_lists:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Module Execution Result:
# ------------------------
#
# "parsed": [
#         {
#             "afi": "ipv4",
#             "prefix_lists": [
#                 {
#                     "description": "this is test description"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "le": 15,
#                             "prefix": "1.0.0.0/8",
#                             "sequence": 5
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 10,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 10
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 15,
#                             "prefix": "12.0.0.0/8",
#                             "sequence": 15
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 20,
#                             "le": 21,
#                             "prefix": "14.0.0.0/8",
#                             "sequence": 20
#                         }
#                     ],
#                     "name": "10"
#                 },
#                 {
#                     "description": "this is test"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 15,
#                             "prefix": "12.0.0.0/8",
#                             "sequence": 50
#                         }
#                     ],
#                     "name": "test"
#                 },
#                 {
#                     "description": "this is for prefix-list"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 10,
#                             "le": 15,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 5
#                         },
#                         {
#                             "action": "deny",
#                             "ge": 20,
#                             "prefix": "35.0.0.0/8",
#                             "sequence": 10
#                         }
#                     ],
#                     "name": "test_prefix"
#                 }
#             ]
#         },
#         {
#             "afi": "ipv6",
#             "prefix_lists": [
#                 {
#                     "description": "this is ipv6 prefix-list"
#                     "entries": [
#                         {
#                             "action": "deny",
#                             "ge": 80,
#                             "prefix": "2001:DB8:0:4::/64",
#                             "sequence": 10
#                         }
#                     ],
#                     "name": "test_ipv6"
#                 }
#             ]
#         }
#     ]

返回值

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

描述

after

列表 / elements=字符串

生成的配置模型调用。

返回:当更改时

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

before

列表 / elements=字符串

模型调用之前的配置。

返回: 始终

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

命令

列表 / elements=字符串

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

返回: 始终

示例: ["ip prefix-list 10 description this is test description", "ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15"]

作者

  • Sagar Paul (@KB-perByte)

  • Sumit Jaiswal (@justjais)