Skip to content

eos_static_routes

Collection Note

This module is part of the arista.eos collection. To install the collection, use:

ansible-galaxy collection install arista.eos
Added in version 1.0.0.

Synopsis

  • This module configures and manages the attributes of static routes on Arista EOS platforms.

Parameters

Parameter Defaults / Choices Comments
config
list / elements=dict
A list of configurations for static routes.
config.address_families A dictionary specifying the address family to which the static route(s) belong.
config.vrf The VRF to which the static route(s) belong.
running_config
str
This option is used only with state I(parsed).
The value of this option should be the output received from the EOS device by executing the command B(show running-config | grep routes).
The state I(parsed) reads the configuration from C(running_config) option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the I(parsed) key within the result.
state
str
Default: merged
Choices: deleted, merged, overridden, replaced, gathered, rendered, parsed
The state the configuration should be left in.

Notes

Note

  • Tested against Arista EOS 4.24.6F
  • This module works with connection C(network_cli). See the L(EOS Platform Options,../network/user_guide/platform_eos.html).

Examples

# 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

Return Values

Key Data Type Description Returned
after list The resulting configuration model invocation. when changed
before list The configuration prior to the model invocation. always
commands list The set of commands pushed to the remote device. always
gathered list The configuration as structured data transformed for the running configuration fetched from remote host When C(state) is I(gathered)
parsed list The configuration as structured data transformed for the value of C(running_config) option When C(state) is I(parsed)
rendered list The set of CLI commands generated from the value in C(config) option When C(state) is I(rendered)

Authors

  • Gomathi Selvi Srinivasan (@gomathiselvis)