junipernetworks.junos.junos_prefix_lists 模块 – 管理 Junos 设备接口上的前缀列表属性。
注意
此模块是 junipernetworks.junos 集合 (版本 9.1.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install junipernetworks.junos
。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:junipernetworks.junos.junos_prefix_lists
。
junipernetworks.junos 2.1.0 中的新增功能
概要
管理 Junos 网络设备接口上的前缀列表属性。
要求
执行此模块的主机需要以下要求。
ncclient (>=v0.6.4)
xmltodict (>=0.12.0)
参数
参数 |
注释 |
---|---|
提供的 BGP 地址族字典。 |
|
指定地址前缀。 |
|
启用对象存在于动态数据库中。 选项
|
|
指定前缀列表的名称。 |
|
此选项仅在 state 为 *parsed* 时使用。 此选项的值应为通过执行命令 **show policy-options** 从 Junos 设备接收到的输出。 state 为 *parsed* 时,从 |
|
配置应保留的状态。 选项
|
注释
注意
此模块要求在被管理的设备上启用 netconf 系统服务。
此模块与连接
netconf
配合使用。请参阅 Junos OS 平台选项。
已针对 JunOS v18.4R1 进行测试
示例
# Using merged
#
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
#
# [edit]
- name: Merge Junos prefix lists
junipernetworks.junos.junos_prefix_lists:
config:
- name: Internal
address_prefixes:
- 172.16.1.32
- 172.16.3.32
- name: Test1
dynamic_db: true
- name: Test2
address_prefixes:
- 172.16.2.32
- 172.16.7.32
- 172.16.9.32
state: merged
# Task Output
# -------------
#
# before: []
# commands:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
# - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
# - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
# - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
# - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
# - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
# - "</nc:prefix-list></nc:policy-options>"
# after:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.2.32/32
# - 172.16.7.32/32
# - 172.16.9.32/32
# name: Test2
# After state
# -----------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.2.32/32;
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
# Using gathered
#
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.2.32/32;
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
- name: Gather Junos prefix-lists
junipernetworks.junos.junos_prefix_lists:
state: gathered
# Task Output
# -------------
#
# gathered:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.2.32/32
# - 172.16.7.32/32
# - 172.16.9.32/32
# name: Test2
# Using replaced
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.2.32/32;
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
- name: Replace existing Junos prefix-lists configuration with provided config
junipernetworks.junos.junos_prefix_lists:
config:
- name: Test2
address_prefixes:
- 172.16.4.32
- 172.16.8.32
- 172.16.9.32"
state: replaced
# Task Output
# -------------
#
# before:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.2.32/32
# - 172.16.7.32/32
# - 172.16.9.32/32
# name: Test2
# commands:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - <nc:prefix-list delete="delete"><nc:name>Test2</nc:name></nc:prefix-list>
# - "<nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item><nc:name>172.16.4.32</nc:name>"
# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.8.32</nc:name>"
# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.9.32</nc:name>"
# - "</nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
# after:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.4.32/32
# - 172.16.8.32/32
# - 172.16.9.32/32
# name: Test2
# After state
# -----------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.4.32/32;
# 172.16.8.32/32;
# 172.16.9.32/32;
# }
# Using overridden
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.4.32/32;
# 172.16.8.32/32;
# 172.16.9.32/32;
# }
- name: Override Junos prefix-lists configuration with provided configuration
junipernetworks.junos.junos_prefix_lists:
config:
- name: Test2
address_prefixes:
- 172.16.4.32/28
- 172.16.8.32/28
- 172.16.9.32/28
state: overridden
# Task Output
# -------------
#
# before:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.4.32/32
# - 172.16.8.32/32
# - 172.16.9.32/32
# name: Test2
# commands:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - <nc:prefix-list delete="delete"><nc:name>Internal</nc:name>
# - </nc:prefix-list><nc:prefix-list delete="delete"><nc:name>Test1</nc:name>
# - </nc:prefix-list><nc:prefix-list delete="delete"><nc:name>Test2</nc:name>
# - "</nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name><nc:prefix-list-item>"
# - "<nc:name>172.16.4.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
# - "<nc:name>172.16.8.32/28</nc:name></nc:prefix-list-item><nc:prefix-list-item>"
# - "<nc:name>172.16.9.32/28</nc:name></nc:prefix-list-item></nc:prefix-list></nc:policy-options>"
# after:
# - address_prefixes:
# - 172.16.4.32/28
# - 172.16.8.32/28
# - 172.16.9.32/28
# name: Test2
# After state
# -----------
#
# vagrant@vsrx# show policy-options
# prefix-list Test2 {
# 172.16.4.32/28;
# 172.16.8.32/28;
# 172.16.9.32/28;
# }
# Using deleted
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.2.32/32;
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
- name: Delete provided prefix-lists
junipernetworks.junos.junos_prefix_lists:
config:
- name: "Test1"
- name: "Test2"
state: deleted
# Task Output
# -------------
#
# before:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.2.32/32
# - 172.16.7.32/32
# - 172.16.9.32/32
# name: Test2
# commands:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - <nc:prefix-list delete="delete"><nc:name>Test1</nc:name></nc:prefix-list>
# - <nc:prefix-list delete="delete"><nc:name>Test2</nc:name></nc:prefix-list></nc:policy-options>
# after:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# After state
# -----------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
#
# Using deleted without specifying config
# Before state
# ------------
#
# vagrant@vsrx# show policy-options
# prefix-list Internal {
# 172.16.1.32/32;
# 172.16.3.32/32;
# }
# prefix-list Test1 {
# dynamic-db;
# }
# prefix-list Test2 {
# 172.16.2.32/32;
# 172.16.7.32/32;
# 172.16.9.32/32;
# }
- name: Delete complete Junos prefix-lists configuration
junipernetworks.junos.junos_prefix_lists:
state: deleted
# Task Output
# -------------
#
# before:
# - address_prefixes:
# - 172.16.1.32/32
# - 172.16.3.32/32
# name: Internal
# - dynamic_db: true
# name: Test1
# - address_prefixes:
# - 172.16.2.32/32
# - 172.16.7.32/32
# - 172.16.9.32/32
# name: Test2
# commands:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - <nc:prefix-list delete="delete"/></nc:policy-options>
# after: []
# After state
# -----------
#
# vagrant@vsrx# show policy-options
#
# [edit]
# Using parsed
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
# <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
# <version>18.4R1-S2.4</version>
# <policy-options>
# <prefix-list>
# <name>64510</name>
# </prefix-list>
# <prefix-list>
# <name>64500</name>
# <dynamic-db/>
# <prefix-list-item>
# <name>172.16.1.16/28</name>
# </prefix-list-item>
# <prefix-list-item>
# <name>172.16.1.32/28</name>
# </prefix-list-item>
# </prefix-list>
# </policy-options>
# </configuration>
# </rpc-reply>
- name: Parse running prefix-lists configuration
junipernetworks.junos.junos_prefix_lists:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
# Task Output
# -------------
# parsed:
# - name: '64510'
# - address_prefixes:
# - 172.16.1.16/28
# - 172.16.1.32/28
# dynamic_db: true
# name: '64500'
# Using rendered
- name: Render the xml for provided configuration
junipernetworks.junos.junos_prefix_lists:
config:
- name: Internal
address_prefixes:
- 172.16.1.32
- 172.16.3.32
- name: Test1
dynamic_db: true
- name: Test2
address_prefixes:
- 172.16.2.32
- 172.16.7.32
- 172.16.9.32
state: rendered
# Task Output
# -------------
# rendered:
# - <nc:policy-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# - "<nc:prefix-list><nc:name>Internal</nc:name><nc:prefix-list-item><nc:name>172.16.1.32</nc:name>"
# - "</nc:prefix-list-item><nc:prefix-list-item><nc:name>172.16.3.32</nc:name>"
# - "</nc:prefix-list-item></nc:prefix-list><nc:prefix-list><nc:name>Test1</nc:name>"
# - "<nc:dynamic-db/></nc:prefix-list><nc:prefix-list><nc:name>Test2</nc:name>"
# - "<nc:prefix-list-item><nc:name>172.16.2.32</nc:name></nc:prefix-list-item>"
# - "<nc:prefix-list-item><nc:name>172.16.7.32</nc:name></nc:prefix-list-item>"
# - "<nc:prefix-list-item><nc:name>172.16.9.32</nc:name></nc:prefix-list-item>"
# - "</nc:prefix-list></nc:policy-options>"