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 平台上静态路由的属性。

参数

参数

注释

config

列表 / 元素=字典

静态路由配置的列表。

address_families

列表 / 元素=字典

指定静态路由所属地址族的字典。

afi

字符串 / 必需

指定顶级地址族指示符。

选项

  • "ipv4"

  • "ipv6"

routes

列表 / 元素=字典

指定静态路由配置的字典。

dest

字符串 / 必需

目标 IPv4 子网 (CIDR 或地址掩码表示法)。

地址格式为 <v4/v6 地址>/<掩码> 或 <v4/v6 地址> <掩码>。

IPv4 掩码范围为 0-32,IPv6 掩码范围为 0-128。

next_hops

列表 / 元素=字典

要采取的路由细节。

admin_distance

整数

路由的优先级或管理距离 (范围 1-255)。

description

字符串

静态路由的名称。

forward_router_address

字符串

目标接口上的转发路由器的地址。

interface

字符串

要使用的出站接口。对于除“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_label

整数

MPLS 标签

nexthop_grp

字符串

下一跳组

tag

整数

路由标签值 (范围 0 到 4294967295)。

track

字符串

跟踪值 (范围 1-512)。在添加路由之前,必须已经在设备上配置跟踪。

vrf

字符串

目标的 VRF。

vrf

字符串

静态路由所属的 VRF。

running_config

字符串

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

此选项的值应是从 EOS 设备通过执行命令 **show running-config | grep routes** 收到的输出。

状态 *parsed* 从 running_config 选项读取配置并将其转换为 Ansible 结构化数据,该数据符合资源模块的 argspec,然后该值将返回到结果中的 *parsed* 键中。

state

字符串

配置应保留的状态。

选项

  • "deleted"

  • "merged" ← (默认)

  • "overridden"

  • "replaced"

  • "gathered"

  • "rendered"

  • "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

返回值

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

描述

after

列表 / 元素=字符串

生成的配置模型调用。

返回:已更改时

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

before

列表 / 元素=字符串

模型调用之前的配置。

返回:始终

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

commands

列表 / 元素=字符串

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

返回:始终

示例: ["ip route vrf vrf1 192.2.2.0/24 125.2.3.1 93", "ipv6 route 5001::/64 Ethernet1"]

gathered

列表 / 元素=字符串

从远程主机获取的运行配置转换后的结构化数据配置

返回:state 为 *gathered* 时

示例: ["The configuration returned will always be in the same format of the parameters above.\n"]

parsed

列表 / 元素=字符串

running_config 选项的值转换后的结构化数据配置

返回:state已解析 状态时

示例: ["The configuration returned will always be in the same format of the parameters above.\n"]

已渲染

列表 / 元素=字符串

根据config 选项的值生成的CLI命令集

返回:state已渲染 状态时

示例: ["- ip route 165.10.1.0/24 Ethernet1 10.1.1.2 100 - ipv6 route 5001::/64 Ethernet1\n"]

作者

  • Gomathi Selvi Srinivasan (@GomathiselviS)