cisco.ios.ios_ospfv2 – OSPFv2 resource module

Note

This plugin is part of the cisco.ios collection (version 2.5.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.ios.

To use it in a playbook, specify: cisco.ios.ios_ospfv2.

New in version 1.0.0: of cisco.ios

Synopsis

  • This module configures and manages the Open Shortest Path First (OSPF) version 2 on IOS platforms.

Note

This module has a corresponding action plugin.

Parameters

Parameter Choices/Defaults Comments
config
dictionary
A dictionary of OSPF options.
processes
list / elements=dictionary
List of OSPF instance configurations.
address_family
dictionary
Router Address Family configuration mode
default
boolean
    Choices:
  • no
  • yes
Set a command to its defaults
snmp_context
string
Modify snmp parameters
Configure SNMP context name
topology
dictionary
Associate the routing protocol to a topology instance
base
boolean
    Choices:
  • no
  • yes
Entering router topology sub mode
name
string
Routing topology instance name
tid
boolean
    Choices:
  • no
  • yes
Configuring the routing protocol topology tid
Note, please refer vendor documentation for valid values
adjacency
dictionary
To configure control adjacency formation
max_adjacency
integer
Maximum number of adjacencies allowed to be forming
Please refer vendor documentation for valid values
min_adjacency
integer
Initial number of adjacencies allowed to be forming in an area
Please refer vendor documentation for valid values
none
boolean
    Choices:
  • no
  • yes
No initial
areas
list / elements=dictionary
OSPF area parameters
area_id
string
OSPF area ID as a decimal value. Please refer vendor documentation of Valid values.
OSPF area ID in IP address format(e.g. A.B.C.D)
authentication
dictionary
Area authentication
enable
boolean
    Choices:
  • no
  • yes
Enable area authentication
message_digest
boolean
    Choices:
  • no
  • yes
Use IPsec authentication
capability
boolean
    Choices:
  • no
  • yes
Enable area specific capability
Enable exclusion of links from base topology
default_cost
integer
Set the summary default-cost of a NSSA/stub area
Stub's advertised external route metric
Note, please refer vendor documentation for respective valid values
filter_list
list / elements=dictionary
Filter networks between OSPF areas
direction
string / required
    Choices:
  • in
  • out
The direction to apply on the filter networks sent to and from this area.
name
string
Name of an IP prefix-list
nssa
dictionary
Specify a NSSA area
default_information_originate
dictionary
Originate Type 7 default into NSSA area
metric
integer
OSPF default metric
metric_type
integer
    Choices:
  • 1
  • 2
OSPF metric type for default routes
OSPF Link State type
nssa_only
boolean
    Choices:
  • no
  • yes
Limit default advertisement to this NSSA area
no_ext_capability
boolean
    Choices:
  • no
  • yes
Do not send domain specific capabilities into NSSA
no_redistribution
boolean
    Choices:
  • no
  • yes
No redistribution into this NSSA area
no_summary
boolean
    Choices:
  • no
  • yes
Do not send summary LSA into NSSA
set
boolean
    Choices:
  • no
  • yes
Enable a NSSA area
translate
string
    Choices:
  • always
  • suppress-fa
Translate LSA
Always translate LSAs on this ABR
Suppress forwarding address in translated LSAs
ranges
list / elements=dictionary
Summarize routes matching address/mask (border routers only)
address
string
IP address to match
advertise
boolean
    Choices:
  • no
  • yes
Advertise this range (default)
Since, advertise when enabled is not shown in running-config idempotency won't be maintained for the play in the second or next run of the play.
cost
integer
User specified metric for this range
netmask
string
IP mask for address
not_advertise
boolean
    Choices:
  • no
  • yes
DoNotAdvertise this range
sham_link
dictionary
Define a sham link and its parameters
cost
integer
Associate a cost with the sham-link
Cost of the sham-link
Note, please refer vendor documentation for respective valid values
destination
string
IP addr associated with sham-link destination (A.B.C.D)
source
string
IP addr associated with sham-link source (A.B.C.D)
ttl_security
integer
TTL security check
Maximum number of IP hops allowed
stub
dictionary
Specify a stub area
Backbone can not be configured as stub area
no_ext_capability
boolean
    Choices:
  • no
  • yes
Do not send domain specific capabilities into stub area
no_summary
boolean
    Choices:
  • no
  • yes
Do not send summary LSA into stub area
set
boolean
    Choices:
  • no
  • yes
Enable a stub area
auto_cost
dictionary
Calculate OSPF interface cost according to bandwidth
reference_bandwidth
integer
Use reference bandwidth method to assign OSPF cost
Note, refer vendor documentation for respective valid values
set
boolean
    Choices:
  • no
  • yes
Enable OSPF auto-cost
bfd
boolean
    Choices:
  • no
  • yes
BFD configuration commands
Enable BFD on all interfaces
capability
dictionary
Enable specific OSPF feature
lls
boolean
    Choices:
  • no
  • yes
Link-local Signaling (LLS) support
opaque
boolean
    Choices:
  • no
  • yes
Opaque LSA
transit
boolean
    Choices:
  • no
  • yes
Transit Area
vrf_lite
boolean
    Choices:
  • no
  • yes
Do not perform PE specific checks
compatible
dictionary
OSPF router compatibility list
rfc1583
boolean
    Choices:
  • no
  • yes
compatible with RFC 1583
rfc1587
boolean
    Choices:
  • no
  • yes
compatible with RFC 1587
rfc5243
boolean
    Choices:
  • no
  • yes
supports DBD exchange optimization
default_information
dictionary
Control distribution of default information
always
boolean
    Choices:
  • no
  • yes
Always advertise default route
metric
integer
OSPF default metric
Note, refer vendor documentation for respective valid values
metric_type
integer
OSPF metric type for default routes
Note, please refer vendor documentation for respective valid range
originate
boolean
    Choices:
  • no
  • yes
Distribute a default route
route_map
string
Route-map reference name
default_metric
integer
Set metric of redistributed routes
discard_route
dictionary
Enable or disable discard-route installation
external
integer
Discard route for redistributed summarised routes
Administrative distance for redistributed summarised routes
Note, please refer vendor documentation for respective valid range
internal
integer
Discard route for summarised internal routes
Administrative distance for summarised internal routes
Note, please refer vendor documentation for respective valid range
set
boolean
    Choices:
  • no
  • yes
Enable discard-route installation
distance
dictionary
Define an administrative distance
admin_distance
dictionary
OSPF Administrative distance
acl
string
Access-list name/number
address
string
IP Source address
distance
integer
Administrative distance
wildcard_bits
string
Wildcard bits
ospf
dictionary
OSPF distance
external
integer
External type 5 and type 7 routes
inter_area
integer
Inter-area routes
intra_area
integer
Intra-area routes
distribute_list
dictionary
Filter networks in routing updates
acls
list / elements=dictionary
IP access list
direction
string / required
    Choices:
  • in
  • out
Filter incoming and outgoing routing updates.
interface
string
Interface configuration (GigabitEthernet A/B)
Valid with incoming traffic
name
string / required
IP access list name/number
protocol
string
Protocol config (bgp 1).
Valid with outgoing traffic
prefix
dictionary
Filter prefixes in routing updates
direction
string / required
    Choices:
  • in
  • out
Filter incoming and outgoing routing updates.
gateway_name
string
Gateway name for filtering incoming updates based on gateway
interface
string
Interface configuration (GigabitEthernet A/B)
Valid with incoming traffic
name
string / required
Name of an IP prefix-list
protocol
string
Protocol config (bgp 1).
Valid with outgoing traffic
route_map
dictionary
Filter prefixes in routing updates
name
string / required
Route-map name
domain_id
dictionary
OSPF domain-id
ip_address
dictionary
IP address
address
string
OSPF domain ID in IP address format
secondary
boolean
    Choices:
  • no
  • yes
Secondary Domain-ID
null
boolean
    Choices:
  • no
  • yes
Null Domain-ID
domain_tag
integer
OSPF domain-tag which is OSPF domain tag - 32-bit value
Note, please refer vendor documentation for respective valid range
event_log
dictionary
Event Logging
enable
boolean
    Choices:
  • no
  • yes
Enable event Logging
one_shot
boolean
    Choices:
  • no
  • yes
Disable Logging When Log Buffer Becomes Full
pause
boolean
    Choices:
  • no
  • yes
Pause Event Logging
size
integer
Maximum Number of Events Stored in the Event Log
Note, refer vendor documentation for respective valid values
help
boolean
    Choices:
  • no
  • yes
Description of the interactive help system
ignore
boolean
    Choices:
  • no
  • yes
Do not complain about specific event
Do not complain upon receiving LSA of the specified type, MOSPF Type 6 LSA
interface_id
boolean
    Choices:
  • no
  • yes
Source of the interface ID
SNMP MIB ifIndex
ispf
boolean
    Choices:
  • no
  • yes
Enable incremental SPF computation
limit
dictionary
Limit a specific OSPF feature and LS update, DBD, and LS request retransmissions
dc
dictionary
Demand circuit retransmissions
disable
boolean
    Choices:
  • no
  • yes
Disble the feature
number
integer
The maximum number of retransmissions
non_dc
dictionary
Non-demand-circuit retransmissions
disable
boolean
    Choices:
  • no
  • yes
Disble the feature
number
integer
The maximum number of retransmissions
local_rib_criteria
dictionary
Enable or disable usage of local RIB as route criteria
enable
boolean
    Choices:
  • no
  • yes
Enable usage of local RIB as route criteria
forwarding_address
boolean
    Choices:
  • no
  • yes
Local RIB used to validate external/NSSA forwarding addresses
inter_area_summary
boolean
    Choices:
  • no
  • yes
Local RIB used as criteria for inter-area summaries
nssa_translation
boolean
    Choices:
  • no
  • yes
Local RIB used as criteria for NSSA translation
log_adjacency_changes
dictionary
Log changes in adjacency state
detail
boolean
    Choices:
  • no
  • yes
Log all state changes
set
boolean
    Choices:
  • no
  • yes
Log changes in adjacency state
max_lsa
dictionary
Maximum number of non self-generated LSAs to accept
ignore_count
integer
Maximum number of times adjacencies can be suppressed
Note, refer vendor documentation for respective valid values
ignore_time
integer
Number of minutes during which all adjacencies are suppressed
Note, refer vendor documentation for respective valid values
number
integer
Maximum number of non self-generated LSAs to accept
Note, refer vendor documentation for respective valid values
reset_time
integer
Number of minutes after which ignore-count is reset to zero
Note, refer vendor documentation for respective valid values
threshold_value
integer
Threshold value (%) at which to generate a warning msg
Note, refer vendor documentation for respective valid values
warning_only
boolean
    Choices:
  • no
  • yes
Only give a warning message when limit is exceeded
max_metric
dictionary
Set maximum metric
external_lsa
integer
Override external-lsa metric with max-metric value
Overriding metric in external-LSAs
Note, refer vendor documentation for respective valid values
include_stub
boolean
    Choices:
  • no
  • yes
Set maximum metric for stub links in router-LSAs
on_startup
dictionary
Set maximum metric temporarily after reboot
time
integer
Time, in seconds, router-LSAs are originated with max-metric
Note, please refer vendor documentation for respective valid range
wait_for_bgp
boolean
    Choices:
  • no
  • yes
Let BGP decide when to originate router-LSA with normal metric
router_lsa
boolean / required
    Choices:
  • no
  • yes
Maximum metric in self-originated router-LSAs
summary_lsa
integer
Override summary-lsa metric with max-metric value
Note, please refer vendor documentation for respective valid range
maximum_paths
integer
Forward packets over multiple paths
Number of paths
mpls
dictionary
Configure MPLS routing protocol parameters
ldp
dictionary
routing protocol commands for MPLS LDP
autoconfig
dictionary
routing protocol commands for MPLS LDP
area
string
Configure an OSPF area to run MPLS LDP
set
boolean
    Choices:
  • no
  • yes
Configure LDP automatic configuration and set the config
sync
boolean
    Choices:
  • no
  • yes
Configure LDP-IGP Synchronization
traffic_eng
dictionary
Let BGP decide when to originate router-LSA with normal metric
area
string
Configure an ospf area to run MPLS Traffic Engineering
OSPF area ID as a decimal value or in IP address format
autoroute_exclude
string
MPLS TE autoroute exclude
Filter prefixes based on name of an IP prefix-list
interface
dictionary
MPLS TE interface configuration for this OSPF process
area
integer
Advertise MPLS TE information for this interface into area
OSPF area ID as a decimal value
interface_type
string
TE Interface configuration (GigabitEthernet A/B)
mesh_group
dictionary
Traffic Engineering Mesh-Group advertisement
area
string
configure flooding scope as area
id
integer
Mesh Group Id
interface
string
Interface configuration (GigabitEthernet A/B)
multicast_intact
boolean
    Choices:
  • no
  • yes
MPLS TE and PIM interaction
router_id_interface
string
Router Interface configuration (GigabitEthernet A/B)
neighbor
dictionary
Specify a neighbor router
address
string
Neighbor address (A.B.C.D)
cost
integer
OSPF cost for point-to-multipoint neighbor metric
Note, please refer vendor documentation for respective valid range
database_filter
boolean
    Choices:
  • no
  • yes
Filter OSPF LSA during synchronization and flooding for point-to-multipoint neighbor
Filter all outgoing LSA
poll_interval
integer
OSPF dead-router polling interval of non-broadcast neighbor in Seconds
priority
integer
OSPF priority of non-broadcast neighbor priority
network
list / elements=dictionary
Enable routing on an IP network
address
string
Network number
area
string
Set the OSPF area ID
wildcard_bits
string
OSPF wild card bits
nsf
dictionary
Non-stop forwarding
cisco
dictionary
Cisco Non-stop forwarding
disable
boolean
    Choices:
  • no
  • yes
disable helper support
helper
boolean
    Choices:
  • no
  • yes
helper support
ietf
dictionary
IETF graceful restart
disable
boolean
    Choices:
  • no
  • yes
disable helper support
helper
boolean
    Choices:
  • no
  • yes
helper support
strict_lsa_checking
boolean
    Choices:
  • no
  • yes
enable helper strict LSA checking
passive_interface
string
passive_interface param is deprecated and a newer param passive_interfaces with added functionality's is introduced, please meke use of the new available passive_interfaces instead.
Suppress routing updates on an interface (GigabitEthernet A/B)
Interface name with respective interface number
passive_interfaces
dictionary
Suppress routing updates on an interface
default
boolean
    Choices:
  • no
  • yes
Suppress routing updates on all interfaces
interface
dictionary
Suppress/Un-Suppress routing updates on interface
name
list / elements=string
Name of interface (GigabitEthernet A/B)
set_interface
boolean
    Choices:
  • no
  • yes
Suppress/Un-Suppress routing updates
prefix_suppression
boolean
    Choices:
  • no
  • yes
Enable prefix suppression
priority
integer
OSPF topology priority
Note, refer vendor documentation for respective valid values
process_id
integer / required
Process ID
queue_depth
dictionary
Hello/Router process queue depth
hello
dictionary
OSPF Hello process queue depth
max_packets
integer
maximum number of packets in the queue
unlimited
boolean
    Choices:
  • no
  • yes
Unlimited queue depth
update
dictionary
OSPF Router process queue depth
max_packets
integer
maximum number of packets in the queue
unlimited
boolean
    Choices:
  • no
  • yes
Unlimited queue depth
router_id
string
Router-id address for this OSPF process
OSPF router-id in IP address format (A.B.C.D)
shutdown
boolean
    Choices:
  • no
  • yes
Shutdown the router process
summary_address
dictionary
Configure IP address summaries
address
string
IP summary address
mask
string
IP Summary mask
not_advertise
boolean
    Choices:
  • no
  • yes
Do not advertise or translate
nssa_only
boolean
    Choices:
  • no
  • yes
Limit summary to NSSA areas
tag
integer
Set tag
timers
dictionary
Adjust routing timers
lsa
integer
OSPF LSA timers, arrival timer
The minimum interval in milliseconds between accepting the same LSA
Note, refer vendor documentation for respective valid values
pacing
dictionary
OSPF pacing timers
flood
integer
OSPF flood pacing timer
The minimum interval in msec to pace limit flooding on interface
Note, refer vendor documentation for respective valid values
lsa_group
integer
OSPF LSA group pacing timer
Interval in sec between group of LSA being refreshed or maxaged
Note, refer vendor documentation for respective valid values
retransmission
integer
OSPF retransmission pacing timer
The minimum interval in msec between neighbor retransmissions
Note, refer vendor documentation for respective valid values
throttle
dictionary
OSPF throttle timers
lsa
dictionary
OSPF LSA throttle timers
first_delay
integer
Delay to generate first occurrence of LSA in milliseconds
Note, refer vendor documentation for respective valid values
max_delay
integer
Maximum delay between originating the same LSA in milliseconds
Note, refer vendor documentation for respective valid values
min_delay
integer
Minimum delay between originating the same LSA in milliseconds
Note, refer vendor documentation for respective valid values
spf
dictionary
OSPF SPF throttle timers - Delay between receiving a change to SPF calculation in milliseconds - Note, refer vendor documentation for respective valid values
between_delay
integer
Delay between first and second SPF calculation in milliseconds
Note, refer vendor documentation for respective valid values
max_delay
integer
Maximum wait time in milliseconds for SPF calculations
Note, refer vendor documentation for respective valid values
receive_delay
integer
Delay between receiving a change to SPF calculation in milliseconds
Note, refer vendor documentation for respective valid values
traffic_share
boolean
    Choices:
  • no
  • yes
How to compute traffic share over alternate paths
All traffic shared among min metric paths
Use different interfaces for equal-cost paths
ttl_security
dictionary
TTL security check
hops
integer
Maximum number of IP hops allowed
Note, refer vendor documentation for respective valid values
set
boolean
    Choices:
  • no
  • yes
Enable TTL Security on all interfaces
vrf
string
Specify parameters for a VPN Routing/Forwarding instance
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the IOS device by executing the command sh running-config | section ^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
    Choices:
  • merged
  • replaced
  • overridden
  • deleted
  • gathered
  • parsed
  • rendered
The state the configuration should be left in
The states rendered, gathered and parsed does not perform any change on the device.
The state rendered will transform the configuration in config option to platform specific CLI commands which will be returned in the rendered key within the result. For state rendered active connection to remote host is not required.
The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result.
The state parsed reads the configuration from running_config option and transforms it into JSON format as per the resource module parameters and the value is returned in the parsed key within the result. The value of running_config option should be the same format as the output of command show running-config | include ip route|ipv6 route executed on device. For state parsed active connection to remote host is not required.

Notes

Note

  • Tested against Cisco IOSv Version 15.2 on VIRL.

Examples

# Using deleted

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

- name: Delete provided OSPF V2 processes
  cisco.ios.ios_ospfv2:
    config:
      processes:
      - process_id: 1
      - process_id: 200
        vrf: blue
    state: deleted

# Commands Fired:
# ---------------
#
# "commands": [
#        "no router ospf 1"
#    ]

# After state:
# -------------
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in

# Using deleted without any config passed (NOTE: This will delete all OSPFV2 configuration from device)

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

- name: Delete all OSPF processes
  cisco.ios.ios_ospfv2:
    state: deleted

# Commands Fired:
# ---------------
#
# "commands": [
#        "no router ospf 200 vrf blue",
#        "no router ospf 1"
#    ]

# After state:
# -------------
# router-ios#sh running-config | section ^router ospf
# router-ios#

# Using merged

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router-ios#

- name: Merge provided OSPF V2 configuration
  cisco.ios.ios_ospfv2:
    config:
      processes:
      - process_id: 1
        max_metric:
          router_lsa: true
          on_startup:
            time: 110
        areas:
        - area_id: '5'
          capability: true
          authentication:
            enable: true
        - area_id: '10'
          authentication:
            message_digest: true
          nssa:
            default_information_originate:
              metric: 10
            translate: suppress-fa
          default_cost: 10
          filter_list:
          - name: test_prefix_in
            direction: in
          - name: test_prefix_out
            direction: out
        network:
          address: 198.51.100.0
          wildcard_bits: 0.0.0.255
          area: 5
        default_information:
          originate: true
        passive_interfaces:
          default: true
          interface:
            set_interface: False
            name:
              - GigabitEthernet0/1
              - GigabitEthernet0/2
      - process_id: 200
        vrf: blue
        domain_id:
          ip_address:
            address: 192.0.3.1
        max_metric:
          router_lsa: true
          on_startup:
            time: 100
        auto_cost:
          reference_bandwidth: 4
        areas:
        - area_id: '10'
          capability: true
        distribute_list:
          acls:
          - name: 10
            direction: out
          - name: 123
            direction: in
    state: merged

# Commands Fired:
# ---------------
#
#  "commands": [
#         "router ospf 200 vrf blue",
#         "auto-cost reference-bandwidth 4",
#         "distribute-list 10 out",
#         "distribute-list 123 in",
#         "domain-id 192.0.3.1",
#         "max-metric router-lsa on-startup 100",
#         "area 10 capability default-exclusion",
#         "router ospf 1",
#         "default-information originate",
#         "max-metric router-lsa on-startup 110",
#         "network 198.51.100.0 0.0.0.255 area 5",
#         "area 10 authentication message-digest",
#         "area 10 default-cost 10",
#         "area 10 nssa translate type7 suppress-fa",
#         "area 10 nssa default-information-originate metric 10",
#         "area 10 filter-list prefix test_prefix_out out",
#         "area 10 filter-list prefix test_prefix_in in",
#         "area 5 authentication",
#         "area 5 capability default-exclusion"
#         "passive-interface default"
#         "no passive-interface GigabitEthernet0/1"
#     ]

# After state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate
#  passive-interface default
#  no passive-interface GigabitEthernet0/1
#  no passive-interface GigabitEthernet0/2

# Using overridden

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

- name: Override provided OSPF V2 configuration
  cisco.ios.ios_ospfv2:
    config:
      processes:
      - process_id: 200
        vrf: blue
        domain_id:
          ip_address:
            address: 192.0.4.1
        max_metric:
          router_lsa: true
          on_startup:
            time: 200
        maximum_paths: 15
        ttl_security:
          hops: 7
        areas:
        - area_id: '10'
          default_cost: 10
          authentication:
            message_digest: true
      - process_id: 100
        vrf: ospf_vrf
        domain_id:
          ip_address:
            address: 192.0.5.1
        auto_cost:
          reference_bandwidth: 5
        areas:
        - area_id: '5'
          authentication:
            message_digest: true
          nssa:
            default_information_originate:
              metric: 10
            translate: suppress-fa
    state: overridden

# Commands Fired:
# ---------------
#
# "commands": [
#         "no router ospf 1",
#         "router ospf 100 vrf ospf_vrf",
#         "auto-cost reference-bandwidth 5",
#         "domain-id 192.0.5.1",
#         "area 5 authentication message-digest",
#         "area 5 nssa translate type7 suppress-fa",
#         "area 5 nssa default-information-originate metric 10",
#         "router ospf 200 vrf blue",
#         "no auto-cost reference-bandwidth 4",
#         "no distribute-list 10 out",
#         "no distribute-list 123 in",
#         "domain-id 192.0.4.1",
#         "max-metric router-lsa on-startup 200",
#         "maximum-paths 15",
#         "ttl-security all-interfaces hops 7",
#         "area 10 authentication message-digest",
#         "no area 10 capability default-exclusion",
#         "area 10 default-cost 10"
#     ]

# After state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.4.1
#  max-metric router-lsa on-startup 200
#  ttl-security all-interfaces hops 7
#  area 10 authentication message-digest
#  area 10 default-cost 10
#  maximum-paths 15
# router ospf 100 vrf ospf_vrf
#  domain-id 192.0.5.1
#  auto-cost reference-bandwidth 5
#  area 5 authentication message-digest
#  area 5 nssa default-information-originate metric 10
#  area 5 nssa translate type7 suppress-fa

# Using replaced

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

- name: Replaced provided OSPF V2 configuration
  cisco.ios.ios_ospfv2:
    config:
      processes:
      - process_id: 200
        vrf: blue
        domain_id:
          ip_address:
            address: 192.0.4.1
        max_metric:
          router_lsa: true
          on_startup:
            time: 200
        maximum_paths: 15
        ttl_security:
          hops: 7
        areas:
        - area_id: '10'
          default_cost: 10
          authentication:
            message_digest: true
      - process_id: 100
        vrf: ospf_vrf
        domain_id:
          ip_address:
            address: 192.0.5.1
        auto_cost:
          reference_bandwidth: 5
        areas:
        - area_id: '5'
          authentication:
            message_digest: true
          nssa:
            default_information_originate:
              metric: 10
            translate: suppress-fa
    state: replaced

# Commands Fired:
# ---------------
# "commands": [
#         "router ospf 100 vrf ospf_vrf",
#         "auto-cost reference-bandwidth 5",
#         "domain-id 192.0.5.1",
#         "area 5 authentication message-digest",
#         "area 5 nssa translate type7 suppress-fa",
#         "area 5 nssa default-information-originate metric 10",
#         "router ospf 200 vrf blue",
#         "no auto-cost reference-bandwidth 4",
#         "no distribute-list 10 out",
#         "no distribute-list 123 in",
#         "domain-id 192.0.4.1",
#         "max-metric router-lsa on-startup 200",
#         "maximum-paths 15",
#         "ttl-security all-interfaces hops 7",
#         "area 10 authentication message-digest",
#         "no area 10 capability default-exclusion",
#         "area 10 default-cost 10"
#     ]

# After state:
# -------------
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.4.1
#  max-metric router-lsa on-startup 200
#  ttl-security all-interfaces hops 7
#  area 10 authentication message-digest
#  area 10 default-cost 10
#  maximum-paths 15
# router ospf 100 vrf ospf_vrf
#  domain-id 192.0.5.1
#  auto-cost reference-bandwidth 5
#  area 5 authentication message-digest
#  area 5 nssa default-information-originate metric 10
#  area 5 nssa translate type7 suppress-fa
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 5 capability default-exclusion
#  area 5 authentication
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_in in
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

# Using Gathered

# Before state:
# -------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

- name: Gather OSPFV2 provided configurations
  cisco.ios.ios_ospfv2:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
# "gathered": {
#         "processes": [
#             {
#                 "areas": [
#                     {
#                         "area_id": "5",
#                         "authentication": {
#                             "enable": true
#                         },
#                         "capability": true
#                     },
#                     {
#                         "area_id": "10",
#                         "authentication": {
#                             "message_digest": true
#                         },
#                         "default_cost": 10,
#                         "filter_list": [
#                             {
#                                 "direction": "in",
#                                 "name": "test_prefix_in"
#                             },
#                             {
#                                 "direction": "out",
#                                 "name": "test_prefix_out"
#                             }
#                         ],
#                         "nssa": {
#                             "default_information_originate": {
#                                 "metric": 10
#                             },
#                             "translate": "suppress-fa"
#                         }
#                     }
#                 ],
#                 "default_information": {
#                     "originate": true
#                 },
#                 "max_metric": {
#                     "on_startup": {
#                         "time": 110
#                     },
#                     "router_lsa": true
#                 },
#                 "network": {
#                     "address": "198.51.100.0",
#                     "area": "5",
#                     "wildcard_bits": "0.0.0.255"
#                 },
#                 "process_id": 1
#             },
#             {
#                 "areas": [
#                     {
#                         "area_id": "10",
#                         "capability": true
#                     }
#                 ],
#                 "auto_cost": {
#                     "reference_bandwidth": 4
#                 },
#                 "distribute_list": {
#                     "acls": [
#                         {
#                             "direction": "out",
#                             "name": "10"
#                         },
#                         {
#                             "direction": "in",
#                             "name": "123"
#                         }
#                     ]
#                 },
#                 "domain_id": {
#                     "ip_address": {
#                         "address": "192.0.3.1"
#                     }
#                 },
#                 "max_metric": {
#                     "on_startup": {
#                         "time": 100
#                     },
#                     "router_lsa": true
#                 },
#                 "process_id": 200,
#                 "vrf": "blue"
#             }
#         ]
#      }

# After state:
# ------------
#
# router-ios#sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  domain-id 192.0.3.1
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 capability default-exclusion
#  distribute-list 10 out
#  distribute-list 123 in
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa default-information-originate metric 10
#  area 10 nssa translate type7 suppress-fa
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0 0.0.0.255 area 5
#  default-information originate

# Using Rendered

- name: Render the commands for provided  configuration
  cisco.ios.ios_ospfv2:
    config:
      processes:
      - process_id: 1
        max_metric:
          router_lsa: true
          on_startup:
            time: 110
        areas:
        - area_id: '5'
          capability: true
          authentication:
            enable: true
        - area_id: '10'
          authentication:
            message_digest: true
          nssa:
            default_information_originate:
              metric: 10
            translate: suppress-fa
          default_cost: 10
          filter_list:
          - name: test_prefix_in
            direction: in
          - name: test_prefix_out
            direction: out
        network:
          address: 198.51.100.0
          wildcard_bits: 0.0.0.255
          area: 5
        default_information:
          originate: true
      - process_id: 200
        vrf: blue
        domain_id:
          ip_address:
            address: 192.0.3.1
        max_metric:
          router_lsa: true
          on_startup:
            time: 100
        auto_cost:
          reference_bandwidth: 4
        areas:
        - area_id: '10'
          capability: true
        distribute_list:
          acls:
          - name: 10
            direction: out
          - name: 123
            direction: in
    state: rendered

# Module Execution Result:
# ------------------------
#
# "rendered": [
#         "router ospf 200 vrf blue",
#         "auto-cost reference-bandwidth 4",
#         "distribute-list 10 out",
#         "distribute-list 123 in",
#         "domain-id 192.0.3.1",
#         "max-metric router-lsa on-startup 100",
#         "area 10 capability default-exclusion",
#         "router ospf 1",
#         "default-information originate",
#         "max-metric router-lsa on-startup 110",
#         "network 198.51.100.0 0.0.0.255 area 5",
#         "area 10 authentication message-digest",
#         "area 10 default-cost 10",
#         "area 10 nssa translate type7 suppress-fa",
#         "area 10 nssa default-information-originate metric 10",
#         "area 10 filter-list prefix test_prefix_out out",
#         "area 10 filter-list prefix test_prefix_in in",
#         "area 5 authentication",
#         "area 5 capability default-exclusion"
#     ]

# Using Parsed

# File: parsed.cfg
# ----------------
#
# router ospf 100
#  auto-cost reference-bandwidth 5
#  domain-id 192.0.5.1
#  area 5 authentication message-digest
#  area 5 nssa translate type7 suppress-fa
#  area 5 nssa default-information-originate metric 10

- name: Parse the provided configuration with the existing running configuration
  cisco.ios.ios_ospfv2:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Module Execution Result:
# ------------------------
#
# "parsed": {
#         "processes": [
#             {
#                 "areas": [
#                     {
#                         "area_id": "5",
#                         "authentication": {
#                             "message_digest": true
#                         },
#                         "nssa": {
#                             "default_information_originate": {
#                                 "metric": 10
#                             },
#                             "translate": "suppress-fa"
#                         }
#                     }
#                 ],
#                 "auto_cost": {
#                     "reference_bandwidth": 5
#                 },
#                 "domain_id": {
#                     "ip_address": {
#                         "address": "192.0.5.1"
#                     }
#                 },
#                 "process_id": 100
#             }
#         ]
#     }

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
after
dictionary
when changed
The resulting configuration model invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
dictionary
always
The configuration prior to the model invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list / elements=string
always
The set of commands pushed to the remote device.

Sample:
['router ospf 200 vrf blue', 'auto-cost reference-bandwidth 5', 'domain-id 192.0.4.1']


Authors

  • Sumit Jaiswal (@justjais)

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