amnesh.soodar.soodar_ospf_interfaces module – OSPF_interfaces resource module.

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_ospf_interfaces.

New in amnesh.soodar 1.0

Synopsis

  • Manages and configures Open Shortest Path First (OSPF) version 2 and it’s attributes over interface on Soodar platforms.

Parameters

Parameter

Comments

config

list / elements=dictionary

A dictionary of OSPF interfaces options.

address_family

list / elements=dictionary

OSPF interfaces settings on the interfaces in address-family context.

afi

string / required

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

Choices:

  • "ipv4"

  • "ipv6"

authentication

dictionary

Enable authentication

message_digest

boolean

Use message-digest authentication

Choices:

  • false

  • true

null

boolean

Use no authentication

Choices:

  • false

  • true

bfd

boolean

BFD configuration commands

Enable/Disable BFD on this interface

Choices:

  • false

  • true

cost

dictionary

Interface cost

interface_cost

integer

Interface cost or Route cost of this interface

dead-interval

dictionary

Interval after which a neighbor is declared dead

minimal

integer

Set to 1 second and set multiplier for Hellos

Number of Hellos sent within 1 second. Please refer vendor documentation of Valid values.

Valid only with IP OSPF config

time

integer

time in seconds

hello_interval

integer

Time between HELLO packets

Please refer vendor documentation of Valid values.

mtu_ignore

boolean

Ignores the MTU in DBD packets

Choices:

  • false

  • true

network

dictionary

Network type

broadcast

boolean

Specify OSPF broadcast multi-access network

Choices:

  • false

  • true

non_broadcast

boolean

Specify OSPF NBMA network

Choices:

  • false

  • true

point_to_multipoint

boolean

Specify OSPF point-to-multipoint network

Choices:

  • false

  • true

point_to_point

boolean

Specify OSPF point-to-point network

Choices:

  • false

  • true

priority

integer

Router priority. Please refer vendor documentation of Valid values.

process

dictionary

OSPF interfaces process config

area_id

string

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

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

instance_id

integer

Set the OSPF instance based on ID

Valid only with IPv6 OSPF config

retransmit_interval

integer

Time between retransmitting lost link state advertisements. Please refer vendor documentation of Valid values.

transmit-delay

integer

Link state transmit delay. Please refer vendor documentation of Valid values.

name

string / required

Full name of the interface e.g. ge1.

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 ^interface.

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"

  • "rendered"

  • "parsed"

Notes

Note

  • Tested against Soodar Version 21.04

Examples

# Using deleted

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
# interface ge2
#  ip ospf priority 40
#  ip ospf 10 area 20
#  ip ospf cost 30

- name: Delete provided OSPF Interface config
  amnesh.soodar.soodar_ospf_interfaces:
    config:
      - name: ge1
    state: deleted

#  Commands Fired:
#  ---------------
#
#  "commands": [
#         "interface ge1",
#         "no ipv6 ospf priority 20",
#         "no ipv6 ospf transmit-delay 30"
#     ]

# After state:
# -------------
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
# interface ge2
#  ip ospf priority 40
#  ip ospf 10 area 20
#  ip ospf cost 30

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

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
# interface ge2
#  ip ospf priority 40
#  ip ospf 10 area 20
#  ip ospf cost 30


- name: Delete all OSPF config from interfaces
  amnesh.soodar.soodar_ospf_interfaces:
    state: deleted

# Commands Fired:
# ---------------
#
#  "commands": [
#         "interface ge2",
#         "no ip ospf 10 area 20",
#         "no ip ospf cost 30",
#         "no ip ospf priority 40",
#         "interface ge1",
#         "no ipv6 ospf priority 20",
#         "no ipv6 ospf transmit-delay 30"
#     ]

# After state:
# -------------
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
# interface ge2


# Using merged

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# soodar#

- name: Merge provided OSPF Interfaces configuration
  amnesh.soodar.soodar_ospf_interfaces:
    config:
      - name: ge1
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 30
            bfd: true
            cost:
              interface_cost: 5
            dead_interval:
              time: 5
            network:
              broadcast: true
            priority: 25
          - afi: ipv6
            priority: 55
            transmit_delay: 45
    state: merged

#  Commands Fired:
#  ---------------
#
#   "commands": [
#         "interface ge1",
#         "ip ospf 10 area 30",
#         "ip ospf bfd",
#         "ip ospf cost 5",
#         "ip ospf dead-interval 5",
#         "ip ospf network broadcast",
#         "ip ospf priority 25",
#         "ipv6 ospf priority 55",
#         "ipv6 ospf transmit-delay 45"
#     ]

# After state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2


# Using replaced

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2

- name: Replaced provided OSPF Interfaces configuration
  amnesh.soodar.soodar_ospf_interfaces:
    config:
      - name: ge2
        address_family:
          - afi: ipv6
            priority: 20
            transmit_delay: 30
    state: replaced

# Commands Fired:
# ---------------
#  "commands": [
#         "interface ge2",
#         "ipv6 ospf priority 20",
#         "ipv6 ospf transmit-delay 30"
#     ]

# After state:
# -------------
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30


# Using overridden

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2

- name: Override provided OSPF Interfaces configuration
  amnesh.soodar.soodar_ospf_interfaces:
    config:
      - name: ge1
        address_family:
          - afi: ipv6
            priority: 20
            transmit_delay: 30
      - name: ge2
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 20
            cost:
              interface_cost: 30
            priority: 40
    state: overridden

# Commands Fired:
# ---------------
#
#  "commands": [
#         "interface ge2",
#         "ip ospf 10 area 20",
#         "ip ospf cost 30",
#         "ip ospf priority 40",
#         "interface ge1",
#         "ipv6 ospf priority 20",
#         "ipv6 ospf transmit-delay 30",
#         "no ip ospf 10 area 30",
#         "no ip ospf bfd",
#         "no ip ospf cost 5",
#         "no ip ospf dead-interval 5",
#         "no ip ospf network broadcast",
#         "no ip ospf priority 25",
#         "no ip ospf shutdown",
#     ]

# After state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ipv6 ospf 55 area 105
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
#  ipv6 ospf adjacency stagger disable
# interface ge2
#  ip ospf priority 40
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf 10 area 20
#  ip ospf cost 30


# Using Gathered

# Before state:
# -------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2

- name: Gather OSPF Interfaces provided configurations
  amnesh.soodar.soodar_ospf_interfaces:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
#  "gathered": [
#         {
#             "name": "ge2"
#         },
#         {
#             "address_family": [
#                 {
#                     "adjacency": true,
#                     "afi": "ipv4",
#                     "bfd": true,
#                     "cost": {
#                         "interface_cost": 5
#                     },
#                     "dead_interval": {
#                         "time": 5
#                     },
#                     "network": {
#                         "broadcast": true
#                     },
#                     "priority": 25,
#                     "process": {
#                         "area_id": "30",
#                         "id": 10
#                     },
#                     "resync_timeout": 10,
#                 },
#                 {
#                     "adjacency": true,
#                     "afi": "ipv6",
#                     "priority": 55,
#                     "transmit_delay": 45
#                 }
#             ],
#             "name": "ge1"
#         },
#         {
#             "name": "ge0"
#         }
#  ]

# After state:
# ------------
#
# soodar# sh running-config | section ^interface
# interface ge0
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge2


# Using Rendered

- name: Render the commands for provided  configuration
  amnesh.soodar.soodar_ospf_interfaces:
    config:
      - name: ge1
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 30
            adjacency: true
            bfd: true
            cost:
              interface_cost: 5
            dead_interval:
              time: 5
            network:
              broadcast: true
            priority: 25
            resync_timeout: 10
          - afi: ipv6
            adjacency: true
            priority: 55
            transmit_delay: 45
    state: rendered

# Module Execution Result:
# ------------------------
#
#  "rendered": [
#         "interface ge1",
#         "ip ospf 10 area 30",
#         "ip ospf bfd",
#         "ip ospf cost 5",
#         "ip ospf dead-interval 5",
#         "ip ospf network broadcast",
#         "ip ospf priority 25",
#         "ip ospf resync-timeout 10",
#         "ipv6 ospf priority 55",
#         "ipv6 ospf transmit-delay 45"
#     ]


# Using Parsed

# File: parsed.cfg
# ----------------
#
# interface ge2
# interface ge1
#  ip ospf network broadcast
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf bfd
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
# interface ge0

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

# Module Execution Result:
# ------------------------
#
#  "parsed": [
#         },
#         {
#             "name": "ge2"
#         },
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "bfd": true,
#                     "cost": {
#                         "interface_cost": 5
#                     },
#                     "dead_interval": {
#                         "time": 5
#                     },
#                     "network": {
#                         "broadcast": true
#                     },
#                     "priority": 25,
#                     "process": {
#                         "area_id": "30",
#                         "id": 10
#                     },
#                 },
#                 {
#                     "afi": "ipv6",
#                     "priority": 55,
#                     "process": {
#                         "area_id": "45",
#                         "id": 35
#                     },
#                     "transmit_delay": 45
#                 }
#             ],
#             "name": "ge1"
#         },
#         {
#             "name": "ge0"
#         }
#     ]

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: ["interface ge1", "ip ospf 10 area 30", "ip ospf cost 5", "ip ospf priority 25"]

Authors

  • Mahdi Varasteh (@m-varasteh)