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 的设备上的前缀列表配置。
参数
参数 |
注释 |
---|---|
前缀列表配置的列表。 |
|
前缀列表的地址族标识符 (AFI)。 选择
|
|
前缀列表配置的列表。 |
|
指定前缀列表的配置列表 |
|
前缀列表允许或拒绝。 选择
|
|
前缀列表的描述。仅适用于操作“remark”。 |
|
要匹配的精确前缀长度。 |
|
要匹配的最小前缀长度。 |
|
要匹配的最大前缀长度。 |
|
A.B.C.D/LEN 或 A:B::C:D/LEN 格式的 IP 或 IPv6 前缀。仅适用于操作“permit”和“deny” |
|
序列号。 |
|
前缀列表的名称。 |
|
此选项仅与状态 parsed 一起使用。 此选项的值应该是通过执行命令 show running-config prefix-list 从 Iosxr 设备接收的输出。 状态 parsed 从 |
|
配置应保留的状态。 有关更多详细信息,请参阅示例。 使用状态 replaced,对于列出的前缀列表,运行配置中但不在任务中的序列将被否定。 使用状态 overridden,运行配置中但不在任务中的所有前缀列表将被否定。 有关更多详细信息,请参阅示例。 选择
|
注释
注意
针对 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
# !
# !
返回值
常见的返回值记录在此处此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的结果配置。 返回:当更改时 示例: |
|
模块执行之前的配置。 返回:当 state 为 示例: |
|
推送到远程设备的命令集。 返回:当 state 为 示例: |
|
从远程设备收集的关于网络资源的 facts,以结构化数据的形式呈现。 返回:当 state 为 示例: |
|
根据模块 argspec,将 running_config 选项中提供的设备本机配置解析为结构化数据。 返回:当 state 为 示例: |
|
以设备本机格式(离线)呈现任务中提供的配置。 返回:当 state 为 示例: |