amnesh.soodar.soodar_ospfv2 module – Manages and configures Open Shortest Path First (OSPF) version 2 and it’s attributes.

Note

This module is part of the amnesh.soodar collection (version 1.0.0).

To install it, use: ansible-galaxy collection install https://soodar.ir/ansible/amnesh.soodar.tar.gz.

To use it in a playbook, specify: amnesh.soodar.soodar_ospfv2.

New in amnesh.soodar 1.0

Synopsis

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

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

config

dictionary

A dictionary of OSPF options.

processes

list / elements=dictionary

List of OSPF instance configurations.

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

Enable area authentication

Choices:

  • false

  • true

message_digest

boolean

Use IPsec authentication

Choices:

  • false

  • true

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

The direction to apply on the filter networks sent to and from this area.

Choices:

  • "in"

  • "out"

name

string

Name of an IP prefix-list

nssa

dictionary

Specify a NSSA area

no_summary

boolean

Do not send summary LSA into NSSA

Choices:

  • false

  • true

set

boolean

Enable a NSSA area

Choices:

  • false

  • true

translate

string

Translate LSA

Configure for translate election

Always translate LSAs on this ABR

Never translate LSAs on this ABR

Choices:

  • "translate-always"

  • "translate-never"

ranges

list / elements=dictionary

Summarize routes matching address/mask (border routers only)

address

string

IP prefix to match

advertise

boolean

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.

Choices:

  • false

  • true

cost

integer

User specified metric for this range

not_advertise

boolean

DoNotAdvertise this range

Choices:

  • false

  • true

stub

dictionary

Specify a stub area

Backbone can not be configured as stub area

no_summary

boolean

Do not send summary LSA into stub area

Choices:

  • false

  • true

set

boolean

Enable a stub area

Choices:

  • false

  • true

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

Enable OSPF auto-cost

Choices:

  • false

  • true

compatible

dictionary

OSPF router compatibility list

rfc1583

boolean

compatible with RFC 1583

Choices:

  • false

  • true

default_information

dictionary

Control distribution of default information

always

boolean

Always advertise default route

Choices:

  • false

  • true

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

route_map

string

Route-map reference name

default_metric

integer

Set metric of redistributed routes

distance

dictionary

Define an administrative distance

admin_distance

dictionary

OSPF Administrative distance

distance

integer

Administrative distance

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

Filter incoming and outgoing routing updates.

Choices:

  • "out"

name

string / required

IP access list name/number

protocol

string

Protocol config (bgp 1).

Valid with outgoing traffic

log_adjacency_changes

dictionary

Log changes in adjacency state

detail

boolean

Log all state changes

Choices:

  • false

  • true

set

boolean

Log changes in adjacency state

Choices:

  • false

  • true

max_metric

dictionary

Set maximum metric

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

router_lsa

boolean / required

Maximum metric in self-originated router-LSAs

Choices:

  • false

  • true

neighbor

dictionary

Specify a neighbor router

address

string

Neighbor address (A.B.C.D)

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

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

Suppress routing updates on all interfaces

Choices:

  • false

  • true

interface

dictionary

Suppress/Un-Suppress routing updates on interface

name

list / elements=string

Name of interface (GigabitEthernet A/B)

set_interface

boolean

Suppress/Un-Suppress routing updates

Choices:

  • false

  • true

prefix_suppression

boolean

Enable prefix suppression

Choices:

  • false

  • true

priority

integer

OSPF topology priority

Note, refer vendor documentation for respective valid values

process_id

integer / required

Process ID

router_id

string

Router-id address for this OSPF process

OSPF router-id in IP address format (A.B.C.D)

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

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

delay

integer

Delay of all LSA parameters 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

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 Soodar 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

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.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "parsed"

  • "rendered"

Notes

Note

  • Tested against Soodar Version 21.04

Examples

# Using Deleted
#
# Before state
# -------------
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 0 range 192.168.19.0/24 not-advertise
#  area 0 range 192.168.19.0/24 cost 10
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 0 authentication
#  area 1 authentication message-digest
#  area 1 nssa translate-never
#  area 1 default-cost 10
#  area 1 filter-list prefix test_prefix_in in
#  area 1 filter-list prefix test_prefix_out out
#  network 198.51.100.0/24 area 0
#  default-information originate

- name: Delete provided OSPF processes
  amnesh.soodar.soodar_ospfv2:
    config:
      processes:
        - id: 1
        - id: 200
          vrf: blue
    state: deleted

#
#
# ------------------------
# Module Execution Results
# ------------------------
# "commands": [
#        "no router ospf 200 vrf blue",
#        "no router ospf 1"
#    ]

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


# Using Merged
#
# Before state
# -------------
# soodar# sh running-config | section ^router ospf
# soodar#

- name: Merge provided configuration
  amnesh.soodar.soodar_ospfv2:
    config:
      processes:
        - process_id: 1
          max_metric:
            router_lsa: true
            on_startup:
              time: 110
          areas:
            - area_id: "5"
              authentication:
                enable: true
            - area_id: "10"
              authentication:
                message_digest: true
              nssa:
                translate: never-translate
              default_cost: 10
              filter_list:
                - name: test_prefix_in
                  direction: in
                - name: test_prefix_out
                  direction: out
          network:
            address: 198.51.100.0/24
            area: 5
          default_information:
            originate: true
        - process_id: 200
          vrf: blue
          max_metric:
            router_lsa: true
            on_startup:
              time: 100
          auto_cost:
            reference_bandwidth: 4
          areas:
            - area_id: "10"
              ranges:
                - address: 192.168.19.0/24
                  not_advertise: true
                  cost: 10
          distribute_list:
            acls:
              - name: 10
                direction: out
    state: merged

# ------------------------
# Module Execution Results
# ------------------------
#
# "commands": [
#        "router ospf 200 vrf blue",
#        "auto-cost reference-bandwidth 4",
#        "distribute-list 10 out",
#        "max-metric router-lsa on-startup 100",
#        "area 10 range 192.168.19.0/24 cost 10",
#        "area 10 range 192.168.19.0/24 not-advertise",
#        "router ospf 1",
#        "default-information originate",
#        "max-metric router-lsa on-startup 110",
#        "network 198.51.100.0/24 area 5",
#        "area 10 authentication message-digest",
#        "area 10 default-cost 10",
#        "area 10 nssa translate translate-never",
#        "area 10 filter-list prefix test_prefix_out out",
#        "area 10 filter-list prefix test_prefix_in in",
#        "area 5 authentication",
#    ]

# After state
# ------------
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  area 10 range 192.168.19.0/24 cost 10
#  area 10 range 192.168.19.0/24 not-advertise
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 5 authentication
#  area 10 authentication message-digest
#  area 10 nssa translate translate-never
#  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/24 area 5
#  default-information originate


# Using replaced

# Before state:
# -------------
#
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa translate translate-never
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0/24 area 5
#  default-information originate

- name: Replaced provided OSPF V2 configuration
  amnesh.soodar.soodar_ospfv2:
    config:
      processes:
      - process_id: 200
        vrf: blue
        max_metric:
          router_lsa: true
          on_startup:
            time: 200
        areas:
        - area_id: '10'
          default_cost: 10
          authentication:
            message_digest: true
      - process_id: 100
        vrf: ospf_vrf
        auto_cost:
          reference_bandwidth: 5
        areas:
        - area_id: '5'
          authentication:
            message_digest: true
          nssa:
            translate: translate-never
    state: replaced

# Commands Fired:
# ---------------
# "commands": [
#         "router ospf 100 vrf ospf_vrf",
#         "auto-cost reference-bandwidth 5",
#         "area 5 authentication message-digest",
#         "area 5 nssa translate translate-never",
#         "router ospf 200 vrf blue",
#         "no auto-cost reference-bandwidth 4",
#         "no distribute-list 10 out",
#         "max-metric router-lsa on-startup 200",
#         "area 10 authentication message-digest",
#         "area 10 default-cost 10"
#     ]

# After state:
# -------------
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  area 10 authentication message-digest
#  area 10 default-cost 10
# router ospf 100 vrf ospf_vrf
#  auto-cost reference-bandwidth 5
#  area 5 authentication message-digest
#  area 5 nssa translate translate-never
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 5 authentication
#  area 10 authentication message-digest
#  area 10 nssa translate translate-never
#  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/24 area 5
#  default-information originate


# Before state:
# -------------
#
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 10 authentication message-digest
#  area 10 nssa translate translate-never
#  area 10 default-cost 10
#  area 10 filter-list prefix test_prefix_out out
#  network 198.51.100.0/24 area 5
#  default-information originate

- name: Override provided OSPF V2 configuration
  amnesh.soodar.soodar_ospfv2:
    config:
      processes:
      - process_id: 200
        vrf: blue
        max_metric:
          router_lsa: true
          on_startup:
            time: 200
        areas:
        - area_id: '10'
          default_cost: 10
          authentication:
            message_digest: true
      - process_id: 100
        vrf: ospf_vrf
        auto_cost:
          reference_bandwidth: 5
        areas:
        - area_id: '5'
          authentication:
            message_digest: true
          nssa:
            translate: translate-never
    state: overridden

# Commands Fired:
# ---------------
#
# "commands": [
#         "no router ospf 1",
#         "router ospf 100 vrf ospf_vrf",
#         "auto-cost reference-bandwidth 5",
#         "area 5 authentication message-digest",
#         "area 5 nssa translate translate-never",
#         "router ospf 200 vrf blue",
#         "no auto-cost reference-bandwidth 4",
#         "no distribute-list 10 out",
#         "max-metric router-lsa on-startup 200",
#         "area 10 authentication message-digest",
#         "area 10 default-cost 10"
#     ]

# After state:
# -------------
#
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 200
#  area 10 authentication message-digest
#  area 10 default-cost 10
# router ospf 100 vrf ospf_vrf
#  auto-cost reference-bandwidth 5
#  area 5 authentication message-digest
#  area 5 nssa translate translate-never


# Using Gathered
#
# Before state
# -------------
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 0 authentication
#  area 1 authentication message-digest
#  area 1 nssa translate-never
#  area 1 default-cost 10
#  area 1 filter-list prefix test_prefix_out out
#  network 198.51.100.0/24 area 0
#  default-information originate

- name: Gather OSPF V2 provided configuration
  amnesh.soodar.soodar_ospfv2:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
# "gathered": {
#         "processes": [
#             {
#                 "areas": [
#                     {
#                         "area_id": "5",
#                         "authentication": {
#                             "enable": 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": {
#                             "translate": "translate-never"
#                         }
#                     }
#                 ],
#                 "default_information": {
#                     "originate": true
#                 },
#                 "max_metric": {
#                     "on_startup": {
#                         "time": 110
#                     },
#                     "router_lsa": true
#                 },
#                 "network": {
#                     "address": "198.51.100.0/24",
#                     "area": "5",
#                 },
#                 "process_id": 1
#             },
#             {
#                 "areas": [
#                     {
#                         "area_id": "10",
#                     }
#                 ],
#                 "auto_cost": {
#                     "reference_bandwidth": 4
#                 },
#                 "distribute_list": {
#                     "acls": [
#                         {
#                             "direction": "out",
#                             "name": "10"
#                         },
#                     ]
#                 },
#                 "max_metric": {
#                     "on_startup": {
#                         "time": 100
#                     },
#                     "router_lsa": true
#                 },
#                 "process_id": 200,
#                 "vrf": "blue"
#             }
#         ]
#      }

# After state:
# ------------
#
# soodar# sh running-config | section ^router ospf
# router ospf 200 vrf blue
#  max-metric router-lsa on-startup 100
#  auto-cost reference-bandwidth 4
#  distribute-list 10 out
# router ospf 1
#  max-metric router-lsa on-startup 110
#  area 0 authentication
#  area 1 authentication message-digest
#  area 1 nssa translate-never
#  area 1 default-cost 10
#  area 1 filter-list prefix test_prefix_out out
#  network 198.51.100.0/24 area 0
#  default-information originate


# Using Rendered

- name: Render the commands for provided  configuration
  amnesh.soodar.soodar_ospfv2:
    config:
      processes:
      - process_id: 1
        max_metric:
          router_lsa: true
          on_startup:
            time: 110
        areas:
        - area_id: '5'
          authentication:
            enable: true
        - area_id: '10'
          authentication:
            message_digest: true
          nssa:
            translate: translate-never
          default_cost: 10
          filter_list:
          - name: test_prefix_in
            direction: in
          - name: test_prefix_out
            direction: out
        network:
          address: 198.51.100.0/24
          area: 5
        default_information:
          originate: true
      - process_id: 200
        vrf: blue
        max_metric:
          router_lsa: true
          on_startup:
            time: 100
        auto_cost:
          reference_bandwidth: 4
        areas:
        - area_id: '10'
        distribute_list:
          acls:
          - name: 10
            direction: out
    state: rendered

# Module Execution Result:
# ------------------------
#
# "rendered": [
#         "router ospf 200 vrf blue",
#         "auto-cost reference-bandwidth 4",
#         "distribute-list 10 out",
#         "max-metric router-lsa on-startup 100",
#         "router ospf 1",
#         "default-information originate",
#         "max-metric router-lsa on-startup 110",
#         "network 198.51.100.0/24 area 5",
#         "area 10 authentication message-digest",
#         "area 10 default-cost 10",
#         "area 10 nssa translate translate-never",
#         "area 10 filter-list prefix test_prefix_out out",
#         "area 10 filter-list prefix test_prefix_in in",
#         "area 5 authentication",
#     ]


# Using Parsed

# File: parsed.cfg
# ----------------
#
# router ospf 100
#  auto-cost reference-bandwidth 5
#  area 5 authentication message-digest
#  area 5 nssa translate translate-never

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

# Module Execution Result:
# ------------------------
#
# "parsed": {
#         "processes": [
#             {
#                 "areas": [
#                     {
#                         "area_id": "5",
#                         "authentication": {
#                             "message_digest": true
#                         },
#                         "nssa": {
#                             "translate": "translate-never"
#                         }
#                     }
#                 ],
#                 "auto_cost": {
#                     "reference_bandwidth": 5
#                 },
#                 "process_id": 100
#             }
#         ]
#     }

Return Values

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

Key

Description

after

dictionary

The resulting configuration model invocation.

Returned: when changed

Sample: "The configuration returned will always be in the same format of the parameters above.\n"

before

dictionary

The configuration prior to the model invocation.

Returned: always

Sample: "The configuration returned will always be in the same format of the parameters above.\n"

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

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

Authors

  • Mahdi Varasteh (@m-varasteh)