arista.eos.eos_static_routes 模块 – 静态路由资源模块
注意
此模块是 arista.eos 集合 (版本 10.0.1) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install arista.eos
。
要在 playbook 中使用它,请指定:arista.eos.eos_static_routes
。
arista.eos 1.0.0 中的新增功能
概要
此模块配置和管理 Arista EOS 平台上静态路由的属性。
参数
参数 |
注释 |
---|---|
静态路由配置的列表。 |
|
指定静态路由所属地址族的字典。 |
|
指定顶级地址族指示符。 选项
|
|
指定静态路由配置的字典。 |
|
目标 IPv4 子网 (CIDR 或地址掩码表示法)。 地址格式为 <v4/v6 地址>/<掩码> 或 <v4/v6 地址> <掩码>。 IPv4 掩码范围为 0-32,IPv6 掩码范围为 0-128。 |
|
要采取的路由细节。 |
|
路由的优先级或管理距离 (范围 1-255)。 |
|
静态路由的名称。 |
|
目标接口上的转发路由器的地址。 |
|
要使用的出站接口。对于除“null0”以外的任何内容,还应配置下一跳 IP 地址。 下一跳路由器的 IP 地址或 null0 Null0 接口或 ethernet e_num 以太网接口或 loopback l_num 环回接口或 management m_num 管理接口或 port-channel p_num vlan v_num vxlan vx_num Nexthop-Group 指定下一跳组名称 Tunnel 隧道接口 vtep 配置 VXLAN 隧道端点 |
|
MPLS 标签 |
|
下一跳组 |
|
路由标签值 (范围 0 到 4294967295)。 |
|
跟踪值 (范围 1-512)。在添加路由之前,必须已经在设备上配置跟踪。 |
|
目标的 VRF。 |
|
静态路由所属的 VRF。 |
|
此选项仅与状态 *parsed* 一起使用。 此选项的值应是从 EOS 设备通过执行命令 **show running-config | grep routes** 收到的输出。 状态 *parsed* 从 |
|
配置应保留的状态。 选项
|
备注
注意
针对 Arista EOS 4.24.6F 进行了测试
此模块与连接
network_cli
一起使用。请参见 EOS 平台选项。
示例
# Using deleted
# Before State:
# ------------
# veos(config)#show running-config | grep route
# ip route vrf testvrf 22.65.1.0/24 Null0 90 name testroute
# ipv6 route 5222:5::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Ethernet1 55
# ipv6 route vrf testvrf 2222:6::/64 Null0 90 name testroute1
# veos(config)#
- name: Delete afi
arista.eos.eos_static_routes:
config:
- vrf: testvrf
address_families:
- afi: ipv4
state: deleted
# Task Output
# -------------
# before:
# - address_families:
# - afi: ipv6
# routes:
# - dest: 5222:5::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 22.65.1.0/24
# next_hops:
# - admin_distance: 90
# description: testroute
# interface: Null0
# - afi: ipv6
# routes:
# - dest: 2222:6::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - admin_distance: 55
# interface: Ethernet1
# - admin_distance: 90
# description: testroute1
# interface: Null0
# vrf: testvrf
# commands:
# - no ip route vrf testvrf 22.65.1.0/24 Null0 90 name testroute
# after:
# - address_families:
# - afi: ipv6
# routes:
# - dest: 5222:5::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - address_families:
# - afi: ipv6
# routes:
# - dest: 2222:6::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - admin_distance: 55
# interface: Ethernet1
# - admin_distance: 90
# description: testroute1
# interface: Null0
# vrf: testvrf
# After State
# ___________
# veos(config)#show running-config | grep route
# ipv6 route 5222:5::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Ethernet1 55
# ipv6 route vrf testvrf 2222:6::/64 Null0 90 name testroute1
# Using merged
# Before State
# -------------
# veos(config)#show running-config | grep "route"
# ip route 165.10.1.0/24 Ethernet1 100
# ip route 172.17.252.0/24 Nexthop-Group testgroup
# ip route vrf testvrf 130.1.122.0/24 Ethernet1 tag 50
# ipv6 route 5001::/64 Ethernet1 50
# veos(config)#
- name: Merge new static route configuration
arista.eos.eos_static_routes:
config:
- vrf: testvrf
address_families:
- afi: ipv6
routes:
- dest: 2211::0/64
next_hop:
- forward_router_address: 100:1::2
interface: Ethernet1
state: merged
# Task Output
# -------------
# before:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hops:
# - admin_distance: 100
# interface: Ethernet1
# - dest: 172.17.252.0/24
# next_hops:
# - nexthop_grp: testgroup
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hops:
# - admin_distance: 50
# interface: Ethernet1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 130.1.122.0/24
# next_hops:
# - interface: Ethernet1
# tag: 50
# vrf: testvrf
# commands:
# - ipv6 route 2211::/64 Ethernet1 100:1::2
# after:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hops:
# - admin_distance: 100
# interface: Ethernet1
# - dest: 172.17.252.0/24
# next_hops:
# - nexthop_grp: testgroup
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hops:
# - admin_distance: 50
# interface: Ethernet1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 130.1.122.0/24
# next_hops:
# - interface: Ethernet1
# tag: 50
# - afi: ipv6
# routes:
# - dest: 2211::0/64
# next_hops:
# - aforward_router_address: "100:1::2"
# interface: Ethernet1
# vrf: testvrf
# After State
# -----------
# veos(config)#show running-config | grep "route"
# ip route 165.10.1.0/24 Ethernet1 100
# ip route 172.17.252.0/24 Nexthop-Group testgroup
# ip route vrf testvrf 130.1.122.0/24 Ethernet1 tag 50
# ipv6 route 2211::/64 Ethernet1 100:1::2
# ipv6 route 5001::/64 Ethernet1 50
# veos(config)#
# Using overridden
# Before State
# -------------
# veos(config)#show running-config | grep "route"
# ip route 165.10.1.0/24 Ethernet1 100
# ip route 172.17.252.0/24 Nexthop-Group testgroup
# ip route vrf testvrf 130.1.122.0/24 Ethernet1 tag 50
# ipv6 route 5001::/64 Ethernet1 50
# veos(config)#
- name: Overridden static route configuration
arista.eos.eos_static_routes:
config:
- address_families:
- afi: ipv4
routes:
- dest: 10.2.2.0/24
next_hop:
- interface: Ethernet1
state: replaced
# Task Output
# -------------
# before:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hops:
# - admin_distance: 100
# interface: Ethernet1
# - dest: 172.17.252.0/24
# next_hops:
# - nexthop_grp: testgroup
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hops:
# - admin_distance: 50
# interface: Ethernet1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 130.1.122.0/24
# next_hops:
# - interface: Ethernet1
# tag: 50
# vrf: testvrf
# commands:
# - no ip route 165.10.1.0/24 Ethernet1 100
# - no ip route 172.17.252.0/24 Nexthop-Group testgroup
# - no ip route vrf testvrf 130.1.122.0/24 Ethernet1 tag 50
# - no ipv6 route 5001::/64 Ethernet1 50
# - ip route 10.2.2.0/24 Ethernet1
# after:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 10.2.2.0/24
# next_hops:
# - interface: Ethernet1
# After State
# -----------
# veos(config)#show running-config | grep "route"
# ip route 10.2.2.0/24 Ethernet1
# veos(config)#
# Using replaced
# Before State
# -------------
# ip route 10.2.2.0/24 Ethernet1
# ip route 10.2.2.0/24 64.1.1.1 label 17 33
# ip route 33.33.33.0/24 Nexthop-Group testgrp
# ip route vrf testvrf 22.65.1.0/24 Null0 90 name testroute
# ipv6 route 5222:5::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Ethernet1 55
# ipv6 route vrf testvrf 2222:6::/64 Null0 90 name testroute1
- name: Replace nexthop
arista.eos.eos_static_routes:
config:
- vrf: testvrf
address_families:
- afi: ipv6
routes:
- dest: 2222:6::/64
next_hops:
- admin_distance: 56
interface: Ethernet1
state: replaced
# Task Output
# -------------
# before:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 10.2.2.0/24
# next_hops:
# - interface: Ethernet1
# - admin_distance: 33
# interface: 64.1.1.1
# mpls_label: 17
# - dest: 33.33.33.0/24
# next_hops:
# - nexthop_grp: testgrp
# - afi: ipv6
# routes:
# - dest: 5222:5::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 22.65.1.0/24
# next_hops:
# - admin_distance: 90
# description: testroute
# interface: Null0
# - afi: ipv6
# routes:
# - dest: 2222:6::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - admin_distance: 90
# description: testroute1
# interface: Null0
# vrf: testvrf
# commands:
# - no ipv6 route vrf testvrf 2222:6::/64 Management1 4312:100::1
# - no ipv6 route vrf testvrf 2222:6::/64 Ethernet1 55
# - no ipv6 route vrf testvrf 2222:6::/64 Null0 90 name testroute1
# - ipv6 route vrf testvrf 2222:6::/64 Ethernet1 56
# after:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 10.2.2.0/24
# next_hops:
# - interface: Ethernet1
# - admin_distance: 33
# interface: 64.1.1.1
# mpls_label: 17
# - dest: 33.33.33.0/24
# next_hops:
# - nexthop_grp: testgrp
# - afi: ipv6
# routes:
# - dest: 5222:5::/64
# next_hops:
# - forward_router_address: 4312:100::1
# interface: Management1
# - address_families:
# - afi: ipv4
# routes:
# - dest: 22.65.1.0/24
# next_hops:
# - admin_distance: 90
# description: testroute
# interface: Null0
# - afi: ipv6
# routes:
# - dest: 2222:6::/64
# next_hops:
# - admin_distance: 56
# interface: Ethernet1
# vrf: testvrf
# After State
# -----------
# veos(config)#show running-config | grep route
# ip route 10.2.2.0/24 Ethernet1
# ip route 10.2.2.0/24 64.1.1.1 label 17 33
# ip route 33.33.33.0/24 Nexthop-Group testgrp
# ip route vrf testvrf 22.65.1.0/24 Null0 90 name testroute
# ipv6 route 5222:5::/64 Management1 4312:100::1
# ipv6 route vrf testvrf 2222:6::/64 Ethernet1 55
# Using Gathered
# Before State
# -------------
# veos(config)#show running-config | grep "route"
# ip route 165.10.1.0/24 Ethernet1 10.1.1.2 100
# ipv6 route 5001::/64 Ethernet1
# veos(config)#
- name: Gather the exisitng condiguration
arista.eos.eos_static_routes:
state: gathered
# Task Output
# -------------
# gathered:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hop:
# - forward_router_address: 10.1.1.2
# interface: Ethernet1
# admin_distance: 100
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hop:
# - interface: Ethernet1
# Using rendered
# arista.eos.eos_static_routes:
# config:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hop:
# - forward_router_address: 10.1.1.2
# interface: "Ethernet1"
# admin_distance: 100
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hop:
# - interface: "Ethernet1"
# Task Output
# -------------
# rendered:
# - ip route 165.10.1.0/24 Ethernet1 10.1.1.2 100
# - ipv6 route 5001::/64 Ethernet1
# Using parsed:
# parse_static_routes.cfg
# ip route 165.10.1.0/24 Ethernet1 10.1.1.2 100
# ipv6 route 5001::/64 Ethernet1
#
- name: parse configs
arista.eos.eos_static_routes:
running_config: "{{ lookup('file', './parse_static_routes.cfg') }}"
state: parsed
# Task Output
# -------------
# parsed:
# - address_families:
# - afi: ipv4
# routes:
# - dest: 165.10.1.0/24
# next_hop:
# - forward_router_address: 10.1.1.2
# interface: Ethernet1
# admin_distance: 100
# - afi: ipv6
# routes:
# - dest: 5001::/64
# next_hop:
# - interface: Ethernet1
返回值
常见的返回值在此处记录 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
生成的配置模型调用。 返回:已更改时 示例: |
|
模型调用之前的配置。 返回:始终 示例: |
|
推送到远程设备的命令集。 返回:始终 示例: |
|
从远程主机获取的运行配置转换后的结构化数据配置 返回: 示例: |
|
为 返回:当 示例: |
|
根据 返回:当 示例: |