cisco.iosxr.iosxr_ospf_interfaces module – Resource module to configure OSPF interfaces.

Note

This module is part of the cisco.iosxr collection (version 4.1.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cisco.iosxr.

To use it in a playbook, specify: cisco.iosxr.iosxr_ospf_interfaces.

New in cisco.iosxr 1.2.0

Synopsis

  • This module manages OSPF(v2/v3) configuration of interfaces on devices running Cisco IOS-XR.

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of OSPF configuration for interfaces.

address_family

list / elements=dictionary

OSPF settings on the interfaces in address-family context.

afi

string / required

Address Family Identifier (AFI) for OSPF settings on the interfaces.

Choices:

  • "ipv4"

  • "ipv6"

apply_group_option

dictionary

Specify configuration from a group

group_name

string

Specify the name of the group

operation

string

Specify the group config operation

Choices:

  • "add"

  • "remove"

  • "append"

authentication

dictionary

Enable authentication

message_digest

dictionary

Use message-digest authentication

keychain

string

Specify keychain name

null_auth

boolean

Use no authentication

Choices:

  • false

  • true

authentication_key

dictionary

Specify authentication password (key)

clear

string

Specifies an UNENCRYPTED password (key) will follow

encrypted

string

Specifies an ENCRYPTED password (key) will follow

password

string

The OSPFv2 password (key)

bfd

dictionary

Configure BFD parameters

fast_detect

dictionary

Configure fast detection

set

boolean

Enable fast detection only

Choices:

  • false

  • true

strict_mode

boolean

Hold down neighbor session until BFD session is up

Choices:

  • false

  • true

minimum_interval

integer

Hello interval in milli-seconds

multiplier

integer

Detect multiplier

cost

integer

Specify Interface cost

cost_fallback

dictionary

Specify Cost when cumulative bandwidth goes below the theshold

cost

integer

Specify cost w.r.t cummulative bandwidth

threshold

integer

Specify threshold bandwidth when cost-fallback is applied

database_filter

dictionary

Filter OSPF LSAs during synchronization and flooding

all_outgoing_lsa

boolean

Filter all outgoing LSA

Choices:

  • false

  • true

dead_interval

integer

Specify interval after which a neighbor is declared dead

demand_circuit

boolean

Enable/Disable demand circuits

Choices:

  • false

  • true

fast_reroute

dictionary

Specify IP Fast Reroute

disabled

boolean

Disable IP fast reroute

Choices:

  • false

  • true

dictionary

Specify per-prefix computation

string

Specify per-link LFA exclusion or FRR LFA candidate information

Choices:

  • "exclude"

  • "lfa_candidate"

dictionary

Specify Per-link LFA exclusion information

list / elements=dictionary

Specify Aggregated Ethernet interface(s)

integer

Specify the interface id

list / elements=dictionary

Specify Bridge-Group Virtual Interface

integer

Specify the interface id

list / elements=dictionary

Specify FastEthernet/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify FiftyGigE/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify FortyGigE/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify FourHundredGigE/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify GigabitEthernet/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify HundredGigE/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify MgmtEth/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify Multilink network interface(s)

string

Specify the interface id

list / elements=dictionary

Specify Network Virtualization Endpoint Interface(s)

integer

Specify the interface id

list / elements=dictionary

Specify Aggregated pos interface(s)

integer

Specify the interface id

list / elements=dictionary

Specify PWHE Ethernet Interface

integer

Specify the interface id

list / elements=dictionary

Specify PWHE VC11 IP Interworking Interface

integer

Specify the interface id

list / elements=dictionary

Specify Serial network interface(s)

string

Specify the interface id

list / elements=dictionary

Specify SRP interface(s)

string

Specify the interface id

list / elements=dictionary

Specify TenGigabitEthernet/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify GRE/IPinIP Tunnel Interface(s)

integer

Specify the interface id

list / elements=dictionary

Specify IPSec Tunnel interface(s)

integer

Specify the interface id

list / elements=dictionary

MPLS Transport Protocol Tunnel interface

string

Specify the interface id

list / elements=dictionary

Specify MPLS Traffic Engineering P2MP Tunnel interface(s)

integer

Specify the interface id

list / elements=dictionary

Specify TwentyFiveGigabitEthernet/IEEE 802.3 interface(s)

string

Specify the interface id

list / elements=dictionary

Specify TwoHundredGigE/IEEE 802.3 interface(s)

string

Specify the interface id

boolean

Enable/Disable backup selection from candidate-list only

Choices:

  • false

  • true

flood_reduction

boolean

Enable/Disable flood reduction

Choices:

  • false

  • true

hello_interval

integer

Specify Time between HELLO packets

boolean

Configure interface down parameters

Choices:

  • false

  • true

message_digest_key

dictionary

Message digest authentication password (key)

id

integer / required

Key ID

md5

dictionary / required

Use MD5 Algorithm

clear

boolean

Specifies an UNENCRYPTED password (key) will follow

Choices:

  • false

  • true

encrypted

boolean

Specifies an ENCRYPTED password (key) will follow

Choices:

  • false

  • true

password

string

The OSPFv2 password (key)

mpls_ldp_sync

boolean

Enable/Disable MPLS LDP Sync

Choices:

  • false

  • true

mtu_ignore

boolean

Enable/Disable ignoring of MTU in DBD packets

Choices:

  • false

  • true

neighbors

list / elements=dictionary

Specify a neighbor routers

cost

integer

Specify OSPF cost for point-to-multipoint neighbor

db_filter_all_out

boolean

Specify Filter OSPF LSA during synchronization and flooding for point-to-multipoint neighbor

Choices:

  • false

  • true

neighbor_id

string

Specify Neighbor address (name)

poll_interval

integer

Specify OSPF dead-router polling interval

priority

integer

Specify OSPF priority of non-broadcast neighbor

network

string

Specify Network type

Choices:

  • "broadcast"

  • "non-broadcast"

  • "point-to-multipoint"

  • "point-to-point"

packet_size

integer

Customize size of OSPF packets upto MTU

passive

boolean

Enable/Disable passive

Choices:

  • false

  • true

prefix_suppression

boolean

Suppress advertisement of the prefixes

Choices:

  • false

  • true

priority

integer

Specify Router priority

processes

list / elements=dictionary

Interfaces configuration for an OSPF process.

area

dictionary

Specify the area-id

area_id

string

OSPF interfaces area ID as a decimal value. Please refer vendor documentation of Valid values.

OSPF interfaces area ID in IP address format(e.g. A.B.C.D)

process_id

string / required

OSPF process tag.

retransmit_interval

integer

Specify time between retransmitting lost link state advertisements

security_ttl

dictionary

Enable security

hops

integer

Maximum number of IP hops allowed <1-254>

set

boolean

Enable ttl security

Choices:

  • false

  • true

transmit_delay

integer

Specify estimated time needed to send link-state update packet

name

string / required

Name/Identifier of the interface.

type

string / required

Type of the interface.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the IOS-XR device by executing the command show running-config router ospf’.

The state parsed reads the configuration from 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 parsed key within the result.

state

string

The state the configuration should be left in.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "parsed"

  • "rendered"

Notes

Note

Examples

# Using merged

# Before state:
# -------------
#
# RP/0/RP0/CPU0:anton#show running-config router ospf
# % No such configuration item(s)
#

- name: Merge provided OSPF interfaces configuration with the existing configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: "LAB3"
                area:
                  area_id: 0.0.0.3
            cost: 20
            authentication:
              message_digest:
                keychain: cisco
          - afi: ipv6
            processes:
              - process_id: "LAB3"
                area:
                  area_id: 0.0.0.2
            cost: 30
    state: merged

#
#
# ------------------------
# Module Execution Result
# ------------------------
#
#  "before": []
#
#  "commands": [
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20",
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest",
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco",
#        "router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30"
#     ]
#
#  "after": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "cisco"
#                         }
#                     },
#                     "cost": 20,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 },
#                 {
#                     "afi": "ipv6",
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.2"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#
#
# ------------
# After state
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:00:57.217 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospf ipv4
# !

# Using replaced
#
# ------------
# Before state
# ------------
#
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:00:57.217 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospf ipv4
# !

- name: Replace OSPF interfaces configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: "LAB3"
                area:
                  area_id: 0.0.0.3
            cost: 30
            authentication:
              message_digest:
                keychain: ciscoiosxr
          - afi: ipv6
            processes:
              - process_id: "LAB3"
                area:
                  area_id: 0.0.0.2
            cost: 30
    state: replaced

#
#
# ------------------------
# Module Execution Result
# ------------------------
#
#  "before": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "cisco"
#                         }
#                     },
#                     "cost": 20,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 },
#                 {
#                     "afi": "ipv6",
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.2"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#
#  "commands": [
#    "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 30",
#    "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest",
#    "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain ciscoiosxr"
#     ]
#
#  "after": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "ciscoiosxr"
#                         }
#                     },
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 },
#                 {
#                     "afi": "ipv6",
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.2"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#
#
# -----------
# After state
# -----------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:10:39.827 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 30
#    authentication message-digest keychain ciscoiosxr
#   !
#  !
# !
# router ospf ipv4
# !

- name: Override existing OSPF interfaces configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/1
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: "LAB1"
                area:
                  area_id: 0.0.0.3
            cost: 10
            authentication:
              message_digest:
                keychain: iosxr
    state: overridden

#
#
# ------------------------
# Module Execution Result
# ------------------------
#
#  "before": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "ciscoiosxr"
#                         }
#                     },
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 },
#                 {
#                     "afi": "ipv6",
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.2"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#
#  "commands": [
#         "no router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0",
#         "no router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0",
#         "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 cost 10",
#         "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest",
#         "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest keychain iosxr"
#     ]
#
#  "after": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "iosxr"
#                         }
#                     },
#                     "cost": 10,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB1"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/1",
#             "type": "gigabitethernet"
#         }
#     ]
#
#
# -----------
# After state
# -----------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:28:15.025 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/1
#    cost 10
#    authentication message-digest keychain iosxr
#   !
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#  !
# !
# router ospf ipv4
# !

# Using deleted
#
# ------------
# Before state
# ------------
#
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:28:15.025 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/1
#    cost 10
#    authentication message-digest keychain iosxr
#   !
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#  !
# !
# router ospf ipv4
# !

- name: Deleted existing OSPF interfaces from the device
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/1
        type: gigabitethernet
    state: deleted

#
#
# ------------------------
# Module Execution Result
# ------------------------
#
#  "before": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "iosxr"
#                         }
#                     },
#                     "cost": 10,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB1"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/1",
#             "type": "gigabitethernet"
#         }
#     ],
#
#  "commands": [
#         "no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1"
#     ]
#
#  "after": []
#
#
# -----------
# After state
# -----------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:34:38.319 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#  !
# !
# router ospf ipv4
# !

# Using parsed
# parsed.cfg
# ------------
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospf ipv4
# !
- name: Parsed the device configuration to get output commands
  cisco.iosxr.iosxr_ospf_interfaces:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "cisco"
#                         }
#                     },
#                     "cost": 20,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#
# Using rendered
#
#
- name: Render the commands for provided  configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
             - process_id: "LAB3"
               area:
                 area_id: 0.0.0.3
            cost: 20
            authentication:
              message_digest:
                keychain: cisco
          - afi: ipv6
            processes:
             - process_id: "LAB3"
               area:
                 area_id: 0.0.0.2
            cost: 30
    state: rendered

#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "rendered": [
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20",
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest",
#        "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco",
#        "router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30"
#     ]


# Using gathered
#
# Before state:
# -------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:50:38.743 UTC
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospf ipv4
# !


- name: Gather ospf_interfaces routes configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "gathered": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "authentication": {
#                         "message_digest": {
#                             "keychain": "cisco"
#                         }
#                     },
#                     "cost": 20,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.3"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 },
#                 {
#                     "afi": "ipv6",
#                     "cost": 30,
#                     "processes": [
#                         {
#                             "area": {
#                                 "area_id": "0.0.0.2"
#                             },
#                             "process_id": "LAB3"
#                         }
#                     ]
#                 }
#             ],
#             "name": "GigabitEthernet0/0/0/0",
#             "type": "gigabitethernet"
#         }
#     ]
#

Authors

  • Rohit Thakur (@rohitthakur2590)