Resource module to configure OSPFv2.
Version added: 1.0.0
- This module configures and manages the Open Shortest Path First (OSPF) version 2 on IOS platforms.
Note
- Tested against Cisco IOSXE Version 17.3 on CML.
- This module works with connection
network_cli
. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html
# 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
# Task Output:
# ------------
# before: {}
# commands:
# - router ospf 200 vrf blue
# - auto-cost reference-bandwidth 4
# - domain-id 192.0.3.1
# - max-metric router-lsa on-startup 100
# - area 10 capability default-exclusion
# - distribute-list 10 out
# - distribute-list 123 in
# - router ospf 1
# - default-information originate
# - max-metric router-lsa on-startup 110
# - area 5 capability default-exclusion
# - area 10 authentication message-digest
# - area 10 default-cost 10
# - area 10 nssa default-information-originate metric 10
# - area 10 nssa translate type7 suppress-fa
# - 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
# - passive-interface default
# - no passive-interface GigabitEthernet0/1
# - no passive-interface GigabitEthernet0/2
# after:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '5'
# 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
# passive_interfaces:
# default: true
# interface:
# name:
# - GigabitEthernet2
# - GigabitEthernet1
# set_interface: false
# process_id: 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 5 capability default-exclusion
# 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
# passive-interface default
# no passive-interface GigabitEthernet1
# no passive-interface GigabitEthernet2
# network 198.51.100.0 0.0.0.255 area 5
# default-information originate
# 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 5 capability default-exclusion
# 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
# passive-interface default
# no passive-interface GigabitEthernet1
# no passive-interface GigabitEthernet2
# network 198.51.100.0 0.0.0.255 area 5
# default-information originate
- name: Replace running config with 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
# Task Output:
# ------------
#
# before:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '5'
# 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
# passive_interfaces:
# default: true
# interface:
# name:
# - GigabitEthernet2
# - GigabitEthernet1
# set_interface: false
# process_id: 1
#
# 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:
# processes:
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# domain_id:
# ip_address:
# address: 192.0.4.1
# max_metric:
# on_startup:
# time: 200
# router_lsa: true
# maximum_paths: 15
# process_id: 200
# ttl_security:
# hops: 7
# vrf: blue
# - areas:
# - area_id: '5'
# authentication:
# message_digest: true
# nssa:
# default_information_originate:
# metric: 10
# translate: suppress-fa
# auto_cost:
# reference_bandwidth: 5
# set: true
# domain_id:
# ip_address:
# address: 192.0.5.1
# process_id: 100
# vrf: ospf_vrf
# - 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
# 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 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
# Task Output:
# ------------
# before:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# filter_list:
# - 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
#
# 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:
# processes:
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# domain_id:
# ip_address:
# address: 192.0.4.1
# max_metric:
# on_startup:
# time: 200
# router_lsa: true
# maximum_paths: 15
# process_id: 200
# ttl_security:
# hops: 7
# vrf: blue
# - areas:
# - area_id: '5'
# authentication:
# message_digest: true
# nssa:
# default_information_originate:
# metric: 10
# translate: suppress-fa
# auto_cost:
# reference_bandwidth: 5
# set: true
# domain_id:
# ip_address:
# address: 192.0.5.1
# process_id: 100
# vrf: ospf_vrf
#
# 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 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
# Task Output:
# ------------
# before:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# filter_list:
# - 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
#
# commands:
# - no router ospf 1
#
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# 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
# Task Output:
# ------------
# before:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# filter_list:
# - 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
#
# commands:
# - no router ospf 200 vrf blue
# - no router ospf 1
#
# after: {}
#
# After state:
# ------------
# router-ios#sh running-config | section ^router ospf
# router-ios#
# 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 running configurations
cisco.ios.ios_ospfv2:
config:
state: gathered
# Task Output:
# ------------
#
# gathered:
# processes:
# - areas:
# - area_id: '10'
# capability: true
# auto_cost:
# reference_bandwidth: 4
# set: true
# 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
# - areas:
# - area_id: '10'
# authentication:
# message_digest: true
# default_cost: 10
# filter_list:
# - 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
# 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
# Task Output:
# ------------
# 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
# Task Output:
# ------------
# parsed:
# processes:
# - areas:
# - area_id: '5'
# authentication:
# message_digest: true
# nssa:
# default_information_originate:
# metric: 10
# translate: suppress-fa
# auto_cost:
# reference_bandwidth: 5
# set: true
# domain_id:
# ip_address:
# address: 192.0.5.1
# process_id: 100
Common return values are documented here, the following are the fields unique to this module:
- Sumit Jaiswal (@justjais)
- Vinay M (@roverflow)