Resource module to configure OSPF interfaces.
Version added: 1.2.0
- This module manages OSPF(v2/v3) configuration of interfaces on devices running Cisco IOS-XR.
Note
- This module works with connection
network_cli
. See the IOS-XR Platform Options
# 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
#
#
# Task Output:
# ------------
#
# 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 LAB3
# area 0.0.0.3
# interface GigabitEthernet0/0/0/0
# cost 20
# authentication message-digest keychain cisco
# !
# !
# !
# router ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
# 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 LAB3
# area 0.0.0.3
# interface GigabitEthernet0/0/0/0
# cost 20
# authentication message-digest keychain cisco
# !
# !
# !
# router ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
- 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
#
# Task Output:
# ------------
#
# 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 LAB3
# area 0.0.0.3
# interface GigabitEthernet0/0/0/0
# cost 30
# authentication message-digest keychain ciscoiosxr
# !
# router ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
# Using overridden
#
# Before state
# ------------
#
- 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
#
#
# Task Output:
# ------------
#
# 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 LAB1
# 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 ospfv3 LAB3
# area 0.0.0.2
# !
# !
# 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 LAB1
# 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
# interface GigabitEthernet0/0/0/0
# cost 20
# authentication message-digest keychain cisco
# !
# !
# !
# router ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
- name: Deleted existing OSPF interfaces from the device
cisco.iosxr.iosxr_ospf_interfaces:
config:
- name: GigabitEthernet0/0/0/1
type: gigabitethernet
state: deleted
#
# Task Output:
# ------------
#
# 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
# - 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:
# - no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1]
#
# 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:34:38.319 UTC
# router ospf LAB1
# 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 ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
# 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 running config and display structured facts.
cisco.iosxr.iosxr_ospf_interfaces:
running_config: "{{ lookup('file', './parsed.cfg') }}"
state: parsed
#
# Task Output:
# ------------
#
# 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
#
# Task Output:
# ------------
#
# 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 LAB3
# area 0.0.0.3
# interface GigabitEthernet0/0/0/0
# cost 20
# authentication message-digest keychain cisco
# !
# !
# !
# router ospfv3 LAB3
# area 0.0.0.2
# interface GigabitEthernet0/0/0/0
# cost 30
# !
# !
# !
- name: Gather ospf_interfaces routes configuration
cisco.iosxr.iosxr_ospf_interfaces:
state: gathered
#
# Task Output:
# ------------
#
# 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
Common return values are documented here, the following are the fields unique to this module:
- Rohit Thakur (@rohitthakur2590)