Spec-Zone.ru › Ansible

cisco.iosxr.iosxr_static_routes модуль — Модуль ресурсов для настройки статических маршрутов.

Примечание

Этот модуль является частью коллекции cisco.iosxr (версия 9.0.0).

У вас, возможно, уже установлена эта коллекция, если вы используете пакет ansible. Она не включена в ansible-core. Чтобы проверить установку, выполните ansible-galaxy collection list.

Для установки используйте: ansible-galaxy collection install cisco.iosxr.

Для использования в плейбуке укажите: cisco.iosxr.iosxr_static_routes.

Добавлен в cisco.iosxr 1.0.0

  • Обзор
  • Параметры
  • Примеры
  • Возвращаемые значения

Обзор

  • Этот модуль управляет статическими маршрутами на устройствах, работающих на Cisco IOS-XR.

Псевдонимы: static_routes

Параметры

Параметр

Комментарии

config

list / elements=dictionary

Словарь параметров статического маршрута.

address_families

list / elements=dictionary

Словарь, указывающий семейство адресов, к которому принадлежат статические маршруты.

afi

string / required

Указывает основной индикатор семейства адресов.

Варианты:

  • "ipv4"
  • "ipv6"

routes

list / elements=dictionary

Словарь, указывающий конфигурации статических маршрутов.

dest

string / required

IPv4 или IPv6 адрес в нотации CIDR, указывающий целевую сеть для статического маршрута.

next_hops

list / elements=dictionary

Следующие переходы к указанному назначению.

admin_distance

integer

Административное расстояние для этого статического маршрута.

Обратитесь к документации поставщика для допустимых значений.

description

string

Указывает описание этого статического маршрута.

dest_vrf

string

Целевой VRF.

forward_router_address

string

IP-адрес следующего перехода, который может быть использован для достижения целевой сети.

interface

string

Интерфейс, используемый для достижения назначения.

metric

integer

Указывает метрику для этого статического маршрута.

Обратитесь к документации поставщика для допустимых значений.

tag

integer

Указывает числовой тег для этого статического маршрута.

Обратитесь к документации поставщика для допустимых значений.

track

string

Указывает отслеживаемый объект.

Это позволяет отслеживать объекты для статических маршрутов.

tunnel_id

integer

Указывает идентификатор туннеля для маршрута.

Обратитесь к документации поставщика для допустимых значений.

vrflabel

integer

Указывает метку VRF для этого статического маршрута.

Обратитесь к документации поставщика для допустимых значений.

safi

string / required

Указывает последующий индикатор семейства адресов.

Варианты:

  • "unicast"
  • "multicast"

vrf

string

VRF, к которому принадлежат статические маршруты.

running_config

string

Этот параметр используется только с состоянием parsed.

Значение этого параметра должно быть результатом выполнения команды show running-config router static на устройстве IOS-XR.

Состояние parsed считывает конфигурацию из параметра running_config и преобразует её в структурированные данные Ansible в соответствии со спецификацией argspec модуля ресурса, а затем возвращает значение в ключе parsed в результате.

state

string

Состояние, в котором должна остаться конфигурация.

Варианты:

  • "merged" ← (по умолчанию)
  • "replaced"
  • "overridden"
  • "deleted"
  • "gathered"
  • "rendered"
  • "parsed"

Примеры

# Using merged

# Before state
# -------------
# RP/0/RP0/CPU0:ios#show running-config router static
# Sat Feb 22 07:46:30.089 UTC
# % No such configuration item(s)
#
- name: Merge the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_static_routes:
    config:
      - address_families:
          - afi: ipv4
            safi: unicast
            routes:
              - dest: 192.0.2.16/28
                next_hops:
                  - forward_router_address: 192.0.2.10
                    interface: FastEthernet0/0/0/1
                    description: LAB
                    metric: 120
                    tag: 10
                  - interface: FastEthernet0/0/0/5
                    track: ip_sla_1
              - dest: 192.0.2.32/28
                next_hops:
                  - forward_router_address: 192.0.2.11
                    admin_distance: 100
          - afi: ipv6
            safi: unicast
            routes:
              - dest: '2001:db8:1000::/36'
                next_hops:
                  - interface: FastEthernet0/0/0/7
                    description: DC
                  - interface: FastEthernet0/0/0/8
                    forward_router_address: '2001:db8:2000:2::1'
      - vrf: DEV_SITE
        address_families:
          - afi: ipv4
            safi: unicast
            routes:
              - dest: 192.0.2.48/28
                next_hops:
                  - forward_router_address: 192.0.2.12
                    description: DEV
                    dest_vrf: test_1
              - dest: 192.0.2.80/28
                next_hops:
                  - interface: FastEthernet0/0/0/2
                    forward_router_address: 192.0.2.14
                    dest_vrf: test_1
                    track: ip_sla_2
                    vrflabel: 124
    state: merged


# Task Output
# -----------
# before: []
# commands:
# - router static
# - address-family ipv4 unicast
# - 192.0.2.16/28 192.0.2.10 FastEthernet0/0/0/1 description LAB metric 120 tag 10
# - 192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
# - 192.0.2.32/28 192.0.2.11 100
# - address-family ipv6 unicast
# - 2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
# - 2001:db8:1000::/36 2001:db8:2000:2::1 FastEthernet0/0/0/8
# - vrf DEV_SITE
# - address-family ipv4 unicast
# - 192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
# - 192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 track ip_sla_2 vrflabel 124
# after:
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.16/28
#             next_hops:
#               - description: LAB
#                 forward_router_address: 192.0.2.10
#                 interface: FastEthernet0/0/0/1
#                 metric: 120
#                 tag: 10
#               - interface: FastEthernet0/0/0/5
#                 track: ip_sla_1
#           - dest: 192.0.2.32/28
#             next_hops:
#               - admin_distance: 100
#                 forward_router_address: 192.0.2.11
#         safi: unicast
#       - afi: ipv6
#         routes:
#           - dest: 2001:db8:1000::/36
#             next_hops:
#               - description: DC
#                 interface: FastEthernet0/0/0/7
#               - forward_router_address: 2001:db8:2000:2::1
#                 interface: FastEthernet0/0/0/8
#         safi: unicast
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.48/28
#             next_hops:
#               - description: DEV
#                 dest_vrf: test_1
#                 forward_router_address: 192.0.2.12
#           - dest: 192.0.2.80/28
#             next_hops:
#               - dest_vrf: test_1
#                 forward_router_address: 192.0.2.14
#                 interface: FastEthernet0/0/0/2
#                 track: ip_sla_2
#                 vrflabel: 124
#         safi: unicast
#     vrf: DEV_SITE


#
# After state
# -------------
# RP/0/RP0/CPU0:ios#show running-config router static
# Sat Feb 22 07:49:11.754 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

# Using merged to update existing static routes

# Before state
# -------------
# RP/0/RP0/CPU0:ios#show running-config router static
# Sat Feb 22 07:49:11.754 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Update existing static routes configuration using merged
  cisco.iosxr.iosxr_static_routes:
    config:
      - vrf: DEV_SITE
        address_families:
          - afi: ipv4
            safi: unicast
            routes:
              - dest: 192.0.2.48/28
                next_hops:
                  - forward_router_address: 192.0.2.12
                    vrflabel: 2301
                    dest_vrf: test_1
              - dest: 192.0.2.80/28
                next_hops:
                  - interface: FastEthernet0/0/0/2
                    forward_router_address: 192.0.2.14
                    dest_vrf: test_1
                    description: rt_test_1
    state: merged

# Task Output
# -----------
# before:
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.16/28
#             next_hops:
#               - description: LAB
#                 forward_router_address: 192.0.2.10
#                 interface: FastEthernet0/0/0/1
#                 metric: 120
#                 tag: 10
#               - interface: FastEthernet0/0/0/5
#                 track: ip_sla_1
#           - dest: 192.0.2.32/28
#             next_hops:
#               - admin_distance: 100
#                 forward_router_address: 192.0.2.11
#         safi: unicast
#       - afi: ipv6
#         routes:
#           - dest: 2001:db8:1000::/36
#             next_hops:
#               - description: DC
#                 interface: FastEthernet0/0/0/7
#               - forward_router_address: 2001:db8:2000:2::1
#                 interface: FastEthernet0/0/0/8
#         safi: unicast
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.48/28
#             next_hops:
#               - description: DEV
#                 dest_vrf: test_1
#                 forward_router_address: 192.0.2.12
#           - dest: 192.0.2.80/28
#             next_hops:
#               - dest_vrf: test_1
#                 forward_router_address: 192.0.2.14
#                 interface: FastEthernet0/0/0/2
#                 track: ip_sla_2
#                 vrflabel: 124
#         safi: unicast
#     vrf: DEV_SITE
# commands:
# - router static
# - vrf DEV_SITE
# - address-family ipv4 unicast
# - 192.0.2.48/28 vrf test_1 192.0.2.12 description DEV vrflabel 2301
# - 192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 description rt_test_1 track ip_sla_2 vrflabel 124
# after:
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.16/28
#             next_hops:
#               - description: LAB
#                 forward_router_address: 192.0.2.10
#                 interface: FastEthernet0/0/0/1
#                 metric: 120
#                 tag: 10
#               - interface: FastEthernet0/0/0/5
#                 track: ip_sla_1
#           - dest: 192.0.2.32/28
#             next_hops:
#               - admin_distance: 100
#                 forward_router_address: 192.0.2.11
#         safi: unicast
#       - afi: ipv6
#         routes:
#           - dest: 2001:db8:1000::/36
#             next_hops:
#               - description: DC
#                 interface: FastEthernet0/0/0/7
#               - forward_router_address: 2001:db8:2000:2::1
#                 interface: FastEthernet0/0/0/8
#         safi: unicast
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.48/28
#             next_hops:
#               - description: DEV
#                 dest_vrf: test_1
#                 forward_router_address: 192.0.2.12
#                 vrflabel: 2301
#           - dest: 192.0.2.80/28
#             next_hops:
#               - description: rt_test_1
#                 dest_vrf: test_1
#                 forward_router_address: 192.0.2.14
#                 interface: FastEthernet0/0/0/2
#                 track: ip_sla_2
#                 vrflabel: 124
#         safi: unicast
#     vrf: DEV_SITE

# After state
# -------------
# RP/0/RP0/CPU0:ios#show running-config router static
# Sat Feb 22 07:49:11.754 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV vrflabel 2301
#    192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 description rt_test_1 track ip_sla_2 vrflabel 124
#   !
#  !
# !

# Using replaced to replace all next hop entries for a single destination network

# Before state
# --------------

# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 07:59:08.669 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.48/28 GigabitEthernet0/0/0/1 192.0.3.24 vrflabel 2302
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Replace device configurations of static routes with provided configurations
  cisco.iosxr.iosxr_static_routes:
    config:
      - vrf: DEV_SITE
        address_families:
          - afi: ipv4
            safi: unicast
            routes:
              - dest: 192.0.2.48/28
                next_hops:
                  - forward_router_address: 192.0.2.15
                    interface: FastEthernet0/0/0/3
                    description: DEV_NEW
                    dest_vrf: dev_test_2
    state: replaced

# Task Output
# -----------
# before:
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 0.0.0.0/0
#             next_hops:
#               - forward_router_address: 10.0.151.254
#                 interface: MgmtEth0
#           - dest: 192.0.2.16/28
#             next_hops:
#               - description: LAB
#                 forward_router_address: 192.0.2.10
#                 interface: FastEthernet0/0/0/1
#                 metric: 120
#                 tag: 10
#               - interface: FastEthernet0/0/0/5
#                 track: ip_sla_1
#           - dest: 192.0.2.32/28
#             next_hops:
#               - admin_distance: 100
#                 forward_router_address: 192.0.2.11
#         safi: unicast
#       - afi: ipv6
#         routes:
#           - dest: 2001:db8:1000::/36
#             next_hops:
#               - description: DC
#                 interface: FastEthernet0/0/0/7
#               - forward_router_address: 2001:db8:2000:2::1
#                 interface: FastEthernet0/0/0/8
#         safi: unicast
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.48/28
#             next_hops:
#               - description: DEV
#                 dest_vrf: test_1
#                 forward_router_address: 192.0.2.12
#               - forward_router_address: 192.0.3.24
#                 interface: GigabitEthernet0/0/0/1
#                 vrflabel: 2302
#           - dest: 192.0.2.80/28
#             next_hops:
#               - dest_vrf: test_1
#                 forward_router_address: 192.0.2.14
#                 interface: FastEthernet0/0/0/2
#                 track: ip_sla_2
#                 vrflabel: 124
#         safi: unicast
#     vrf: DEV_SITE
# commands:
# - router static
# - vrf DEV_SITE
# - address-family ipv4 unicast
# - no 192.0.2.48/28 vrf test_1 192.0.2.12
# - no 192.0.2.48/28 192.0.3.24 GigabitEthernet0/0/0/1
# - 192.0.2.48/28 vrf dev_test_2 192.0.2.15 FastEthernet0/0/0/3 description DEV_NEW
# after:
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.16/28
#             next_hops:
#               - description: LAB
#                 forward_router_address: 192.0.2.10
#                 interface: FastEthernet0/0/0/1
#                 metric: 120
#                 tag: 10
#               - interface: FastEthernet0/0/0/5
#                 track: ip_sla_1
#           - dest: 192.0.2.32/28
#             next_hops:
#               - admin_distance: 100
#                 forward_router_address: 192.0.2.11
#         safi: unicast
#       - afi: ipv6
#         routes:
#           - dest: 2001:db8:1000::/36
#             next_hops:
#               - description: DC
#                 interface: FastEthernet0/0/0/7
#               - forward_router_address: 2001:db8:2000:2::1
#                 interface: FastEthernet0/0/0/8
#         safi: unicast
#   - address_families:
#       - afi: ipv4
#         routes:
#           - dest: 192.0.2.48/28
#             next_hops:
#               - description: DEV_NEW
#                 dest_vrf: dev_test_2
#                 forward_router_address: 192.0.2.15
#                 interface: FastEthernet0/0/0/3
#           - dest: 192.0.2.80/28
#             next_hops:
#               - dest_vrf: test_1
#                 forward_router_address: 192.0.2.14
#                 interface: FastEthernet0/0/0/2
#                 track: ip_sla_2
#                 vrflabel: 124
#         safi: unicast
#     vrf: DEV_SITE

# After state
# ------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 08:04:07.085 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf dev_test_2 FastEthernet0/0/0/3 192.0.2.15 description DEV_NEW
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

# Using overridden to override all static route entries on the device

# Before state
# -------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 07:59:08.669 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.48/28 GigabitEthernet0/0/0/1 192.0.3.24 vrflabel 2302
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Overridde all static routes configuration with provided configuration
  cisco.iosxr.iosxr_static_routes:
    config:
      - vrf: DEV_NEW
        address_families:
          - afi: ipv4
            safi: unicast
            routes:
              - dest: 192.0.2.48/28
                next_hops:
                  - forward_router_address: 192.0.2.15
                    interface: FastEthernet0/0/0/3
                    description: DEV1
          - afi: ipv6
            safi: unicast
            routes:
              - dest: '2001:db8:3000::/36'
                next_hops:
                  - interface: FastEthernet0/0/0/4
                    forward_router_address: '2001:db8:2000:2::2'
                    description: PROD1
                    track: ip_sla_1
    state: overridden

# Task Output
# -----------
# before:
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.16/28
#               next_hops:
#                 - description: LAB
#                   forward_router_address: 192.0.2.10
#                   interface: FastEthernet0/0/0/1
#                   metric: 120
#                   tag: 10
#                 - interface: FastEthernet0/0/0/5
#                   track: ip_sla_1
#             - dest: 192.0.2.32/28
#               next_hops:
#                 - admin_distance: 100
#                   forward_router_address: 192.0.2.11
#           safi: unicast
#         - afi: ipv6
#           routes:
#             - dest: 2001:db8:1000::/36
#               next_hops:
#                 - description: DC
#                   interface: FastEthernet0/0/0/7
#                 - forward_router_address: 2001:db8:2000:2::1
#                   interface: FastEthernet0/0/0/8
#           safi: unicast
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.48/28
#               next_hops:
#                 - description: DEV
#                   dest_vrf: test_1
#                   forward_router_address: 192.0.2.12
#                 - forward_router_address: 192.0.3.24
#                   interface: GigabitEthernet0/0/0/1
#                   vrflabel: 2302
#             - dest: 192.0.2.80/28
#               next_hops:
#                 - dest_vrf: test_1
#                   forward_router_address: 192.0.2.14
#                   interface: FastEthernet0/0/0/2
#                   track: ip_sla_2
#                   vrflabel: 124
#           safi: unicast
#       vrf: DEV_SITE
# commands:
#     - router static
#     - no vrf DEV_SITE
#     - no address-family ipv4 unicast
#     - no address-family ipv6 unicast
#     - vrf DEV_NEW
#     - address-family ipv4 unicast
#     - 192.0.2.48/28 192.0.2.15 FastEthernet0/0/0/3 description DEV1
#     - address-family ipv6 unicast
#     - 2001:db8:3000::/36 2001:db8:2000:2::2 FastEthernet0/0/0/4 description PROD1
#       track ip_sla_1
# after:
#     - vrf: DEV_NEW
#       address_families:
#         - afi: ipv4
#           safi: unicast
#           routes:
#             - dest: 192.0.2.48/28
#               next_hops:
#                 - forward_router_address: 192.0.2.15
#                   interface: FastEthernet0/0/0/3
#                   description: DEV1
#         - afi: ipv6
#           safi: unicast
#           routes:
#             - dest: 2001:db8:3000::/36
#               next_hops:
#                 - interface: FastEthernet0/0/0/4
#                   forward_router_address: 2001:db8:2000:2::2
#                   description: PROD1
#                   track: ip_sla_1

# After state
# -------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 08:07:41.516 UTC
# router static
#  vrf DEV_NEW
#   address-family ipv4 unicast
#    192.0.2.48/28 FastEthernet0/0/0/3 192.0.2.15 description DEV1
#   !
#   address-family ipv6 unicast
#    2001:db8:3000::/36 FastEthernet0/0/0/4 2001:db8:2000:2::2 description PROD1 track ip_sla_1
#   !
#  !
# !

# Using deleted to delete all destination network entries under a single AFI

# Before state
# -------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 07:59:08.669 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.48/28 GigabitEthernet0/0/0/1 192.0.3.24 vrflabel 2302
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Delete all destination network entries under a single AFI
  cisco.iosxr.iosxr_static_routes:
    config:
      - vrf: DEV_SITE
        address_families:
          - afi: ipv4
            safi: unicast
    state: deleted

# Task output
# -----------------------
# before:
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.16/28
#               next_hops:
#                 - description: LAB
#                   forward_router_address: 192.0.2.10
#                   interface: FastEthernet0/0/0/1
#                   metric: 120
#                   tag: 10
#                 - interface: FastEthernet0/0/0/5
#                   track: ip_sla_1
#             - dest: 192.0.2.32/28
#               next_hops:
#                 - admin_distance: 100
#                   forward_router_address: 192.0.2.11
#           safi: unicast
#         - afi: ipv6
#           routes:
#             - dest: 2001:db8:1000::/36
#               next_hops:
#                 - description: DC
#                   interface: FastEthernet0/0/0/7
#                 - forward_router_address: 2001:db8:2000:2::1
#                   interface: FastEthernet0/0/0/8
#           safi: unicast
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.48/28
#               next_hops:
#                 - description: DEV
#                   dest_vrf: test_1
#                   forward_router_address: 192.0.2.12
#                 - forward_router_address: 192.0.3.24
#                   interface: GigabitEthernet0/0/0/1
#                   vrflabel: 2302
#             - dest: 192.0.2.80/28
#               next_hops:
#                 - dest_vrf: test_1
#                   forward_router_address: 192.0.2.14
#                   interface: FastEthernet0/0/0/2
#                   track: ip_sla_2
#                   vrflabel: 124
#           safi: unicast
#       vrf: DEV_SITE
# commands:
#  - router static
#  - vrf DEV_SITE
#  - no address-family ipv4 unicast
# after:
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.16/28
#               next_hops:
#                 - description: LAB
#                   forward_router_address: 192.0.2.10
#                   interface: FastEthernet0/0/0/1
#                   metric: 120
#                   tag: 10
#                 - interface: FastEthernet0/0/0/5
#                   track: ip_sla_1
#             - dest: 192.0.2.32/28
#               next_hops:
#                 - admin_distance: 100
#                   forward_router_address: 192.0.2.11
#           safi: unicast
#         - afi: ipv6
#           routes:
#             - dest: 2001:db8:1000::/36
#               next_hops:
#                 - description: DC
#                   interface: FastEthernet0/0/0/7
#                 - forward_router_address: 2001:db8:2000:2::1
#                   interface: FastEthernet0/0/0/8
#           safi: unicast
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.48/28
#               next_hops:
#                 - description: DEV
#                   dest_vrf: test_1
#                   forward_router_address: 192.0.2.12
#                 - forward_router_address: 192.0.3.24
#                   interface: GigabitEthernet0/0/0/1
#                   vrflabel: 2302
#             - dest: 192.0.2.80/28
#               next_hops:
#                 - dest_vrf: test_1
#                   forward_router_address: 192.0.2.14
#                   interface: FastEthernet0/0/0/2
#                   track: ip_sla_2
#                   vrflabel: 124
#           safi: unicast
#     - vrf: DEV_SITE

# After state
# ------------

# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 08:16:41.464 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#  !
# !

# Using deleted to remove all static route entries from the device

# Before state
# -------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 07:59:08.669 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.48/28 GigabitEthernet0/0/0/1 192.0.3.24 vrflabel 2302
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Delete static routes configuration
  cisco.iosxr.iosxr_static_routes:
    state: deleted

# Task output
# -----------------------
# before:
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.16/28
#               next_hops:
#                 - description: LAB
#                   forward_router_address: 192.0.2.10
#                   interface: FastEthernet0/0/0/1
#                   metric: 120
#                   tag: 10
#                 - interface: FastEthernet0/0/0/5
#                   track: ip_sla_1
#             - dest: 192.0.2.32/28
#               next_hops:
#                 - admin_distance: 100
#                   forward_router_address: 192.0.2.11
#           safi: unicast
#         - afi: ipv6
#           routes:
#             - dest: 2001:db8:1000::/36
#               next_hops:
#                 - description: DC
#                   interface: FastEthernet0/0/0/7
#                 - forward_router_address: 2001:db8:2000:2::1
#                   interface: FastEthernet0/0/0/8
#           safi: unicast
#     - address_families:
#         - afi: ipv4
#           routes:
#             - dest: 192.0.2.48/28
#               next_hops:
#                 - description: DEV
#                   dest_vrf: test_1
#                   forward_router_address: 192.0.2.12
#                 - forward_router_address: 192.0.3.24
#                   interface: GigabitEthernet0/0/0/1
#                   vrflabel: 2302
#             - dest: 192.0.2.80/28
#               next_hops:
#                 - dest_vrf: test_1
#                   forward_router_address: 192.0.2.14
#                   interface: FastEthernet0/0/0/2
#                   track: ip_sla_2
#                   vrflabel: 124
#           safi: unicast
#       vrf: DEV_SITE
# commands:
#     - no router static
# after: []
# After state
# ------------
# RP/0/RP0/CPU0:ios#sh running-config router static
# Sat Feb 22 08:50:43.038 UTC
# % No such configuration item(s)

# Using gathered to gather static route facts from the device

- name: Gather static routes facts from the device using iosxr_static_routes module
  cisco.iosxr.iosxr_static_routes:
    state: gathered

# Task output (redacted)
# -----------------------
# "gathered": [
#    {
#        "address_families": [
#            {
#                "afi": "ipv4",
#                "routes": [
#                    {
#                        "dest": "192.0.2.16/28",
#                        "next_hops": [
#                            {
#                                "description": "LAB",
#                                "forward_router_address": "192.0.2.10",
#                                "interface": "FastEthernet0/0/0/1",
#                                "metric": 120,
#                                "tag": 10
#                            },
#                            {
#                                "interface": "FastEthernet0/0/0/5",
#                                "track": "ip_sla_1"
#                            }
#                        ]
#                    },
#                    {
#                        "dest": "192.0.2.32/28",
#                        "next_hops": [
#                            {
#                                "admin_distance": 100,
#                                "forward_router_address": "192.0.2.11"
#                            }
#                        ]
#                    }
#                ],
#                "safi": "unicast"
#            },
#            {
#                "afi": "ipv6",
#                "routes": [
#                    {
#                        "dest": "2001:db8:1000::/36",
#                        "next_hops": [
#                            {
#                                "description": "DC",
#                                "interface": "FastEthernet0/0/0/7"
#                            },
#                            {
#                                "forward_router_address": "2001:db8:2000:2::1",
#                                "interface": "FastEthernet0/0/0/8"
#                            }
#                        ]
#                    }
#                ],
#                "safi": "unicast"
#            }
#        ]
#    },
#    {
#        "address_families": [
#            {
#                "afi": "ipv4",
#                "routes": [
#                    {
#                        "dest": "192.0.2.48/28",
#                        "next_hops": [
#                            {
#                                "description": "DEV",
#                                "dest_vrf": "test_1",
#                                "forward_router_address": "192.0.2.12"
#                            },
#                            {
#                                "forward_router_address": "192.0.3.24",
#                                "interface": "GigabitEthernet0/0/0/1",
#                                "vrflabel": 2302
#                            }
#                        ]
#                    },
#                    {
#                        "dest": "192.0.2.80/28",
#                        "next_hops": [
#                            {
#                                "dest_vrf": "test_1",
#                                "forward_router_address": "192.0.2.14",
#                                "interface": "FastEthernet0/0/0/2",
#                                "track": "ip_sla_2",
#                                "vrflabel": 124
#                            }
#                        ]
#                    }
#                ],
#                "safi": "unicast"
#            }
#        ],
#        "vrf": "DEV_SITE"
#    }
#  ]

# Using rendered

- name: Render platform specific commands (without connecting to the device)
  cisco.iosxr.iosxr_static_routes: null
  config:
    - vrf: DEV_SITE
      address_families:
        - afi: ipv4
          safi: unicast
          routes:
            - dest: 192.0.2.48/28
              next_hops:
                - forward_router_address: 192.0.2.12
                  description: DEV
                  dest_vrf: test_1
            - dest: 192.0.2.80/28
              next_hops:
                - interface: FastEthernet0/0/0/2
                  forward_router_address: 192.0.2.14
                  dest_vrf: test_1
                  track: ip_sla_2
                  vrflabel: 124

# Task Output (redacted)
# -----------------------
# "rendered": [
#    "router static"s,
#    "vrf DEV_SITE",
#    "address-family ipv4 unicast",
#    "192.0.2.48/28 vrf test_1 192.0.2.12 description DEV",
#    "192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 track ip_sla_2 vrflabel 124"

# Using parsed

# parsed.cfg
# ------------
# Fri Nov 29 21:10:41.896 UTC
# router static
#  address-family ipv4 unicast
#   192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
#   192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
#   192.0.2.32/28 192.0.2.11 100
#  !
#  address-family ipv6 unicast
#   2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
#   2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
#  !
#  vrf DEV_SITE
#   address-family ipv4 unicast
#    192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
#    192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
#   !
#  !
# !

- name: Use parsed state to convert externally supplied device specific static routes
    commands to structured format
  cisco.iosxr.iosxr_static_routes:
    running_config: "{{ lookup('file', '../../fixtures/parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------
# "parsed": [
#        {
#            "address_families": [
#                {
#                    "afi": "ipv4",
#                    "routes": [
#                        {
#                            "dest": "192.0.2.16/28",
#                            "next_hops": [
#                                {
#                                    "description": "LAB",
#                                    "forward_router_address": "192.0.2.10",
#                                    "interface": "FastEthernet0/0/0/1",
#                                    "metric": 120,
#                                    "tag": 10
#                                },
#                                {
#                                    "interface": "FastEthernet0/0/0/5",
#                                    "track": "ip_sla_1"
#                                }
#                            ]
#                        },
#                        {
#                            "dest": "192.0.2.32/28",
#                            "next_hops": [
#                                {
#                                    "admin_distance": 100,
#                                    "forward_router_address": "192.0.2.11"
#                                }
#                            ]
#                        }
#                    ],
#                    "safi": "unicast"
#                },
#                {
#                    "afi": "ipv6",
#                    "routes": [
#                        {
#                            "dest": "2001:db8:1000::/36",
#                            "next_hops": [
#                                {
#                                    "description": "DC",
#                                    "interface": "FastEthernet0/0/0/7"
#                                },
#                                {
#                                    "forward_router_address": "2001:db8:2000:2::1",
#                                    "interface": "FastEthernet0/0/0/8"
#                                }
#                            ]
#                        }
#                    ],
#                    "safi": "unicast"
#                }
#            ]
#        },
#        {
#            "address_families": [
#                {
#                    "afi": "ipv4",
#                    "routes": [
#                        {
#                            "dest": "192.0.2.48/28",
#                            "next_hops": [
#                                {
#                                    "description": "DEV",
#                                    "dest_vrf": "test_1",
#                                    "forward_router_address": "192.0.2.12"
#                                }
#                            ]
#                        },
#                        {
#                            "dest": "192.0.2.80/28",
#                            "next_hops": [
#                                {
#                                    "dest_vrf": "test_1",
#                                    "forward_router_address": "192.0.2.14",
#                                    "interface": "FastEthernet0/0/0/2",
#                                    "track": "ip_sla_2",
#                                    "vrflabel": 124
#                                }
#                            ]
#                        }
#                    ],
#                    "safi": "unicast"
#                }
#            ],
#            "vrf": "DEV_SITE"
#        }
#    ]
# }

Значения возврата

Общие значения возврата описаны здесь, следующие поля уникальны для данного модуля:

Ключ

Описание

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

список / элементы=строка

Набор команд, отправленных на удалённое устройство.

Возвращается: всегда

Пример: ["router static", "vrf dev_site", "address-family ipv4 unicast", "192.0.2.48/28 192.0.2.12 FastEthernet0/0/0/1 track ip_sla_10 description dev1", "address-family ipv6 unicast", "no 2001:db8:1000::/36", "2001:db8:3000::/36 2001:db8:2000:2::2 FastEthernet0/0/0/4 track ip_sla_11 description prod1"]

Авторы

  • Nilashish Chakraborty (@NilashishC)

Ссылки на коллекцию

  • Система отслеживания ошибок
  • Репозиторий (источники)

© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/cisco/iosxr/iosxr_static_routes_module.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API