junipernetworks.junos.junos_routing_instances 模块 – 管理 Junos 设备上的路由实例。
注意
此模块是 junipernetworks.junos 集合 (版本 9.1.0) 的一部分。
如果您正在使用 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查是否已安装它,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install junipernetworks.junos
。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在剧本中使用它,请指定:junipernetworks.junos.junos_routing_instances
。
junipernetworks.junos 2.1.0 中的新增功能
概要
管理 Junos 网络设备上的路由实例。
要求
执行此模块的主机需要以下要求。
ncclient (>=v0.6.4)
xmltodict (>=0.12.0)
参数
参数 |
注释 |
---|---|
提供的路由实例配置列表。 |
|
桥接域配置。 这已在 Junos MX204 上进行了测试。 |
|
指定域描述。 |
|
提供域 ID。 |
|
在此桥接域中启用由于 mac 移动而导致的阻止操作。 选项
|
|
在此桥接域中启用 IRB MAC 同步 选项
|
|
指定桥接域的名称。 |
|
禁用 irb 路由接口的数据包的第 2 层副本的传输。 选项
|
|
禁用面向 CE 的接口内的本地交换。 选项
|
|
指定服务 ID。 |
|
桥接域的 IEEE 802.1q VLAN 标识符 (1..4094) |
|
通告 connector-id 属性。 选项
|
|
指定路由实例的文本描述。 |
|
出口实例保护字典。 |
|
指定上下文标识符。 |
|
为此 VPN 启用边缘保护功能。 选项
|
|
L2Backhaul-vpn 路由器的主要角色。 选项
|
|
此路由实例的接口名称。 |
|
指定接口的名称。 |
|
指定受保护接口的名称。 |
|
此实例的第 2 层 vpn-id。 |
|
指定路由实例名称。 |
|
禁用 irb 路由接口的数据包的第 2 层副本的传输。 选项
|
|
禁用接口的 VLAN ID 规范化。 选项
|
|
禁用接口的 VLAN ID 规范化。 选项
|
|
禁用接口的 VLAN ID 规范化。 选项
|
|
禁用从 IP 到 MPLS(推送时)和从 MPLS 到 IP(弹出时)的 TTL 传播。 选项
|
|
为 VPLS 实例启用 BUM 修剪。 选项
|
|
此实例的路由区分符 |
|
此路由实例的路由接口名称。 |
|
指定实例类型。 选项
|
|
VRF 实例 RIB 的导出策略。 |
|
VRF 实例 RIB 的导入策略。 |
|
此选项仅与状态 *parsed* 一起使用。 此选项的值应是从 Junos 设备执行命令 **show routing-instances** 收到的输出。 状态 *parsed* 从 |
|
配置应保留的状态。 选项
|
备注
注意
此模块要求在被管理的设备上启用 netconf 系统服务。
此模块与连接
netconf
一起使用。请参阅 Junos OS 平台选项。针对 JunOS v18.4R1 进行了测试
示例
# Using merged
#
# Before state
# ------------
#
# admin# show routing-instances
#
# [edit]
# vagrant@vsrx# show policy-options
# policy-statement test-policy {
# term t1 {
# then reject;
# }
# }
# policy-statement test-policy-1 {
# term t1 {
# then reject;
# }
# }
- name: Merge Junos BGP address family configuration
junipernetworks.junos.junos_routing_instances:
config:
- name: "test"
type: "vrf"
route_distinguisher: "10.58.255.1:37"
vrf_imports:
- "test-policy"
vrf_exports:
- "test-policy"
- "test-policy-1"
interfaces:
- name: "sp-0/0/0.0"
- name: "gr-0/0/0.0"
connector_id_advertise: true
- name: "forwardinst"
type: "forwarding"
description: "Configured by Ansible Content Team"
state: merged
#
# -------------------------
# Module Execution Result
# -------------------------
#
# After state
# -----------
#
# admin# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
#
# Using gathered
#
# Before state
# ------------
#
# admin# show routing-instances
#
# [edit]
# admin# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
- name: Gather Junos routing-instances
junipernetworks.junos.junos_routing_instances:
state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# "gathered": [
# {
# "description": "Configured by Ansible Content Team",
# "name": "forwardinst",
# "type": "forwarding"
# },
# {
# "connector_id_advertise": true,
# "interfaces": [
# {
# "name": "gr-0/0/0.0"
# },
# {
# "name": "sp-0/0/0.0"
# }
# ],
# "name": "test",
# "route_distinguisher": "10.58.255.1:37",
# "type": "vrf",
# "vrf_exports": [
# "test-policy",
# "test-policy-1"
# ],
# "vrf_imports": [
# "test-policy"
# ]
# }
# ]
#
# Using replaced
#
# Before state
# ------------
#
# admin# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
- name: Replace existing Junos routing instance config with provided config
junipernetworks.junos.junos_routing_instances:
config:
address_family:
- name: "test"
type: "vrf"
route_distinguisher: "10.57.255.1:37"
vrf_imports:
- "test-policy"
vrf_exports:
- "test-policy"
interfaces:
- name: "sp-0/0/0.0"
- name: "gr-0/0/0.0"
connector_id_advertise: false
description: "Configured by Ansible Content Team"
state: replaced
# After state
# -----------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# description "Configured by Ansible Content Team";
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.57.255.1:37;
# vrf-import test-policy;
# vrf-export test-policy;
# }
# Using overridden
#
# Before state
# ------------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# description "Configured by Ansible Content Team";
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.57.255.1:37;
# vrf-import test-policy;
# vrf-export test-policy;
# }
- name: Override Junos routing-instances configuration
junipernetworks.junos.junos_routing_instances:
config:
- name: "test"
type: "vrf"
route_distinguisher: "10.58.255.1:37"
vrf_imports:
- "test-policy"
vrf_exports:
- "test-policy"
- "test-policy-1"
interfaces:
- name: "sp-0/0/0.0"
- name: "gr-0/0/0.0"
connector_id_advertise: true
- name: "forwardinst"
type: "forwarding"
description: "Configured by Ansible Content Team"
- name: "vtest1"
type: "virtual-router"
state: overridden
# After state
# -----------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
# vtest1 {
# instance-type virtual-router;
# }
# Using deleted
#
# Before state
# ------------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
- name: Delete provided junos routing-instamce
junipernetworks.junos.junos_routing_instances:
config:
- name: "test"
state: deleted
# After state
# -----------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# Using deleted without config
#
# Before state
# ------------
#
# admin@vsrx# show routing-instances
# forwardinst {
# description "Configured by Ansible Content Team";
# instance-type forwarding;
# }
# test {
# instance-type vrf;
# interface gr-0/0/0.0; ## 'gr-0/0/0.0' is not defined
# interface sp-0/0/0.0; ## 'sp-0/0/0.0' is not defined
# route-distinguisher 10.58.255.1:37;
# vrf-import test-policy;
# vrf-export [ test-policy test-policy-1 ];
# connector-id-advertise;
# }
# vtest1 {
# instance-type virtual-router;
# }
- name: Delete complete Junos routing-instances config
junipernetworks.junos.junos_routing_instances:
config:
state: deleted
# After state
# -----------
#
# admin@vsrx# show routing-instances
#
# [edit]
- name: Gather Junos BGP address family config
junipernetworks.junos.junos_routing_instances:
config:
state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# "gathered": {
# "address_family": [
# {
# "af_type": [
# {
# "accepted_prefix_limit": {
# "idle_timeout_value": 2001,
# "limit_threshold": 98,
# "maximum": 20
# },
# "damping": true,
# "defer_initial_multipath_build": {
# "maximum_delay": 2
# },
# "type": "signaling"
# }
# ],
# "afi": "evpn"
# },
# {
# "af_type": [
# {
# "accepted_prefix_limit": {
# "idle_timeout_value": 2000,
# "limit_threshold": 99,
# "maximum": 20
# },
# "damping": true,
# "defer_initial_multipath_build": {
# "maximum_delay": 2
# },
# "delay_route_advertisements": {
# "max_delay_route_age": 20,
# "max_delay_routing_uptime": 32000,
# "min_delay_inbound_convergence": 32000,
# "min_delay_routing_uptime": 23000
# },
# "graceful_restart_forwarding_state_bit": "from-fib",
# "type": "any"
# },
# {
# "legacy_redirect_ip_action": {
# "receive": true,
# "send": true
# },
# "loops": 4,
# "no_install": true,
# "output_queue_priority_expedited": true,
# "secondary_independent_resolution": true,
# "type": "flow"
# },
# {
# "entropy_label": {
# "no_next_hop_validation": true
# },
# "explicit_null": {
# "connected_only": true
# },
# "per_group_label": true,
# "per_prefix_label": true,
# "prefix_limit": {
# "forever": true,
# "limit_threshold": 99,
# "maximum": 20
# },
# "resolve_vpn": true,
# "rib": "inet.3",
# "route_refresh_priority_priority": 3,
# "type": "labeled-unicast"
# },
# {
# "extended_nexthop": true,
# "extended_nexthop_color": true,
# "local_ipv4_address": "9.9.9.9",
# "type": "unicast"
# }
# ],
# "afi": "inet"
# }
# ]
# }
#
# 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>
# <routing-instances>
# <instance>
# <name>forwardinst</name>
# <description>Configured by Ansible Content Team</description>
# <instance-type>forwarding</instance-type>
# </instance>
# <instance>
# <name>test</name>
# <instance-type>vrf</instance-type>
# <interface>
# <name>gr-0/0/0.0</name>
# </interface>
# <interface>
# <name>sp-0/0/0.0</name>
# </interface>
# <route-distinguisher>
# <rd-type>10.58.255.1:37</rd-type>
# </route-distinguisher>
# <vrf-import>test-policy</vrf-import>
# <vrf-export>test-policy</vrf-export>
# <vrf-export>test-policy-1</vrf-export>
# <connector-id-advertise/>
# </instance>
# </routing-instances>
# </configuration>
# </rpc-reply>
- name: Parse routing instance running config
junipernetworks.junos.junos_routing_instances:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": [
# {
# "description": "Configured by Ansible Content Team",
# "name": "forwardinst",
# "type": "forwarding"
# },
# {
# "connector_id_advertise": true,
# "interfaces": [
# {
# "name": "gr-0/0/0.0"
# },
# {
# "name": "sp-0/0/0.0"
# }
# ],
# "name": "test",
# "route_distinguisher": "10.58.255.1:37",
# "type": "vrf",
# "vrf_exports": [
# "test-policy",
# "test-policy-1"
# ],
# "vrf_imports": [
# "test-policy"
# ]
# }
# ]
#
#
# Using rendered
#
#
- name: Render the xml for provided configuration
junipernetworks.junos.junos_routing_instances:
config:
- name: "test"
type: "vrf"
route_distinguisher: "10.58.255.1:37"
vrf_imports:
- "test-policy"
vrf_exports:
- "test-policy"
- "test-policy-1"
interfaces:
- name: "sp-0/0/0.0"
- name: "gr-0/0/0.0"
connector_id_advertise: true
- name: "forwardinst"
type: "forwarding"
description: "Configured by Ansible Content Team"
state: rendered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "rendered": "<nc:routing-instances xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
# <nc:instance><nc:name>test</nc:name><nc:connector-id-advertise/><nc:instance-type>vrf</nc:instance-type>
# <nc:interface><nc:name>sp-0/0/0.0</nc:name></nc:interface><nc:interface><nc:name>gr-0/0/0.0</nc:name></nc:interface>
# <nc:route-distinguisher><nc:rd-type>10.58.255.1:37</nc:rd-type></nc:route-distinguisher>
# <nc:vrf-import>test-policy</nc:vrf-import><nc:vrf-export>test-policy</nc:vrf-export>
# <nc:vrf-export>test-policy-1</nc:vrf-export></nc:instance>
# <nc:instance><nc:name>forwardinst</nc:name><nc:description>Configured by Ansible Content Team</nc:description>
# <nc:instance-type>forwarding</nc:instance-type></nc:instance></nc:routing-instances>"
返回值
常见的返回值已在 此处 记录,以下是此模块特有的字段
键 |
描述 |
---|---|
生成的配置模型调用。 返回:发生更改时 示例: |
|
模型调用之前的配置。 返回:始终返回 示例: |
|
推送到远程设备的命令集。 返回:始终返回 示例: |