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

注意

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

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

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

要在 playbook 中使用它,请指定:cisco.iosxr.iosxr_prefix_lists

cisco.iosxr 2.3.0 中的新功能

概要

  • 此模块管理运行 Cisco IOSXR 的设备上的前缀列表配置。

参数

参数

注释

config

列表 / 元素=字典

前缀列表配置的列表。

afi

字符串

前缀列表的地址族标识符 (AFI)。

选择

  • "ipv4"

  • "ipv6"

prefix_lists

列表 / 元素=字典

前缀列表配置的列表。

entries

列表 / 元素=字典

指定前缀列表的配置列表

action

字符串

前缀列表允许或拒绝。

选择

  • "permit"

  • "deny"

  • "remark"

description

字符串

前缀列表的描述。仅适用于操作“remark”。

eq

整数

要匹配的精确前缀长度。

ge

整数

要匹配的最小前缀长度。

le

整数

要匹配的最大前缀长度。

prefix

字符串

A.B.C.D/LEN 或 A:B::C:D/LEN 格式的 IP 或 IPv6 前缀。仅适用于操作“permit”和“deny”

sequence

整数

序列号。

name

字符串

前缀列表的名称。

running_config

字符串

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

此选项的值应该是通过执行命令 show running-config prefix-list 从 Iosxr 设备接收的输出。

状态 parsedrunning_config 选项读取配置,并按照资源模块的 argspec 将其转换为 Ansible 结构化数据,然后该值将以结果中的 parsed 键返回。

state

字符串

配置应保留的状态。

有关更多详细信息,请参阅示例。

使用状态 replaced,对于列出的前缀列表,运行配置中但不在任务中的序列将被否定。

使用状态 overridden,运行配置中但不在任务中的所有前缀列表将被否定。

有关更多详细信息,请参阅示例。

选择

  • "merged" ←(默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "gathered"

  • "rendered"

注释

注意

  • 针对 IOSXR 7.0.2 进行了测试。

  • 此模块使用连接 network_cli

示例

# Using merged


# Before state
# RP/0/0/CPU0:10#show running-config
# Thu Feb  4 09:38:36.245 UTC
# % No such configuration item(s)
# RP/0/0/CPU0:10#
#


- name: Merge the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_prefix_lists:
    state: merged
    config:
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: deny
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL_2_REMARK
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_2_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
          - name: pl2
            entries:
              - sequence: 5
                action: remark
                description: TEST_PL2_REMARK
          - name: pl3
            entries:
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0

# Task Output
# -------------
# before: []
# commands:
# - ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48
# - ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK
# - ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK
# - ipv4 prefix-list pl1 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK
# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0
# after:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# After state:
# ------------
# RP/0/0/CPU0:10#show running-config
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMAR
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0
# !


# Using replaced:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
#


- name: >-
    Replace device configurations of listed prefix lists with provided
    configurations
  register: result
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: permit
                prefix: 10.0.0.0/24
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: permit
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL1_2
    state: replaced


# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL_2_REMARK
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_2_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2
# commands:
# - no ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK
# - no ipv4 prefix-list pl1 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl1 3 permit 10.0.0.0/24
# - ipv6 prefix-list pl_2 2 remark TEST_PL1_2
# after:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL1_2
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 3
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2


# After state:
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL1_2
# !
# ipv4 prefix-list pl1
#  3 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
#
# Module Execution:
#


# Using deleted:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0

- name: Delete all prefix-lists from the device
  cisco.iosxr.iosxr_prefix_lists:
    state: deleted

# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0
# commands:
# - no ipv6 prefix-list pl_1
# - no ipv6 prefix-list pl_2
# - no ipv4 prefix-list pl1
# - no ipv4 prefix-list pl2
# - no ipv4 prefix-list pl3
# after: []


# After state:
# RP/0/0/CPU0:10#show running-config
#

# using gathered:


# After state:
# ------------
# RP/0/0/CPU0:10#show running-config
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
# !
# ipv4 prefix-list pl3
#  6 permit 35.0.0.0/8 eq 0
# !


- name: Gather ACL interfaces facts using gathered state
  cisco.iosxr.iosxr_prefix_lists:
    state: gathered

# gathered:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#   - name: pl3
#     entries:
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# Using parsed:


# parsed.cfg
# ------------------------------
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK


- name: Parse externally provided Prefix_lists config to agnostic model
  cisco.iosxr.iosxr_prefix_lists:
    running_config: '{{ lookup(''file'', ''./fixtures/parsed.cfg'') }}'
    state: parsed


# Task Output
# -------------
# parsed:
# - afi: ipv6
#   prefix_lists:
#   - name: pl_1
#     entries:
#     - prefix: 2001:db8:1234::/48
#       action: deny
#       sequence: 1
#   - name: pl_2
#     entries:
#     - sequence: 2
#       action: remark
#       description: TEST_PL_2_REMARK
# - afi: ipv4
#   prefix_lists:
#   - name: pl1
#     entries:
#     - sequence: 3
#       action: remark
#       description: TEST_PL1_2_REMARK
#     - sequence: 4
#       action: permit
#       prefix: 10.0.0.0/24
#   - name: pl2
#     entries:
#     - sequence: 5
#       action: remark
#       description: TEST_PL2_REMARK
#     - sequence: 6
#       action: permit
#       prefix: 35.0.0.0/8
#       eq: 0


# Using rendered:


- name: Render platform specific commands from task input using rendered state
  register: result
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv6
        prefix_lists:
          - name: pl_1
            entries:
              - prefix: '2001:db8:1234::/48'
                action: deny
                sequence: 1
          - name: pl_2
            entries:
              - sequence: 2
                action: remark
                description: TEST_PL_2_REMARK
      - afi: ipv4
        prefix_lists:
          - name: pl1
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_2_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
          - name: pl2
            entries:
              - sequence: 5
                action: remark
                description: TEST_PL2_REMARK
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0
    state: rendered


# Task Output
# -------------
# "rendered": [
#         "ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48",
#         "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK",
#         "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK",
#         "ipv4 prefix-list pl1 4 permit 10.0.0.0/24",
#         "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK",
#         "ipv4 prefix-list pl2 6 permit 35.0.0.0/8 eq 0"
#     ]

# Using overridden:


# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config
#
# ipv6 prefix-list pl_1
#  1 deny 2001:db8:1234::/48
# !
# ipv6 prefix-list pl_2
#  2 remark TEST_PL_2_REMARK
# !
# ipv4 prefix-list pl1
#  3 remark TEST_PL1_2_REMARK
#  4 permit 10.0.0.0/24
# !
# ipv4 prefix-list pl2
#  5 remark TEST_PL2_REMARK
#
- name: Overridde all Prefix_lists configuration with provided configuration
  cisco.iosxr.iosxr_prefix_lists:
    config:
      - afi: ipv4
        prefix_lists:
          - name: pl3
            entries:
              - sequence: 3
                action: remark
                description: TEST_PL1_3_REMARK
              - sequence: 4
                action: permit
                prefix: 10.0.0.0/24
              - sequence: 6
                action: permit
                prefix: 35.0.0.0/8
                eq: 0
    state: overridden


# Task Output
# -------------
# before:
# - afi: ipv6
#   prefix_lists:
#   - entries:
#     - action: deny
#       prefix: 2001:db8:1234::/48
#       sequence: 1
#     name: pl_1
#   - entries:
#     - action: remark
#       description: TEST_PL_2_REMARK
#       sequence: 2
#     name: pl_2
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_2_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     name: pl1
#   - entries:
#     - action: remark
#       description: TEST_PL2_REMARK
#       sequence: 5
#     name: pl2
# commands:
# - no ipv6 prefix-list pl_1
# - no ipv6 prefix-list pl_2
# - no ipv4 prefix-list pl1
# - no ipv4 prefix-list pl2
# - ipv4 prefix-list pl3 3 remark TEST_PL1_3_REMARK
# - ipv4 prefix-list pl3 4 permit 10.0.0.0/24
# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0
# after:
# - afi: ipv4
#   prefix_lists:
#   - entries:
#     - action: remark
#       description: TEST_PL1_3_REMARK
#       sequence: 3
#     - action: permit
#       prefix: 10.0.0.0/24
#       sequence: 4
#     - action: permit
#       prefix: 35.0.0.0/8
#       sequence: 6
#       eq: 0
#     name: pl3


# After state:
# RP/0/0/CPU0:10#show running-config
#
# ipv4 prefix-list pl3
# 3 remark TEST_PL1_3_REMARK
# 4 permit 10.0.0.0/24
# 6 permit 35.0.0.0/8 eq 0
# !
# !

返回值

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

描述

after

字典

模块执行后的结果配置。

返回:当更改时

示例: "此 输出 的格式 将始终 模块 argspec 的格式相同。\n"

before

字典

模块执行之前的配置。

返回:statemergedreplacedoverriddendeletedpurged

示例: "此 输出 的格式 将始终 模块 argspec 的格式相同。\n"

commands

列表 / 元素=字符串

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

返回:statemergedreplacedoverriddendeletedpurged

示例: ["ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", "ipv4 prefix-list pl1 4 permit 10.0.0.0/24", "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK"]

gathered

列表 / 元素=字符串

从远程设备收集的关于网络资源的 facts,以结构化数据的形式呈现。

返回:stategathered

示例: ["此 输出 的格式 将始终 模块 argspec 的格式相同。\n"]

parsed

列表 / 元素=字符串

根据模块 argspec,将 running_config 选项中提供的设备本机配置解析为结构化数据。

返回:stateparsed

示例: ["此 输出 的格式 将始终 模块 argspec 的格式相同。\n"]

rendered

列表 / 元素=字符串

以设备本机格式(离线)呈现任务中提供的配置。

返回:staterendered

示例: ["ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", "ipv4 prefix-list pl1 4 permit 10.0.0.0/24", "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK"]

作者

  • Ashwini Mhatre (@amhatre)