junipernetworks.junos.junos_ospf_interfaces – OSPF Interfaces Resource Module.

Note

This plugin is part of the junipernetworks.junos collection (version 1.3.0).

To install it use: ansible-galaxy collection install junipernetworks.junos.

To use it in a playbook, specify: junipernetworks.junos.junos_ospf_interfaces.

New in version 1.3.0: of junipernetworks.junos

Synopsis

  • This module manages OSPF(v2/v3) configuration of interfaces on devices running Juniper JUNOS.

Note

This module has a corresponding action plugin.

Requirements

The below requirements are needed on the host that executes this module.

  • ncclient (>=v0.6.4)

  • xmltodict (>=0.12.0)

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
A list of OSPF configuration for interfaces.
address_family
list / elements=dictionary
OSPF settings on the interfaces in address-family context.
afi
string / required
    Choices:
  • ipv4
  • ipv6
Address Family Identifier (AFI) for OSPF settings on the interfaces.
processes
dictionary
Interfaces configuration for an OSPF process.
area
dictionary
Specify the area-id
area_id
string
Specify area id.
authentication
dictionary
Specify authentication type
md5
dictionary
Specify md5 based authentication.
key_id
string
Specify md5 key-id
key_value
string
Specify key value
start_time
string
Specify start time for key transmission
simple_password
string
Specify password for authentication.
bandwidth_based_metrics
list / elements=dictionary
Specify list of bandwidth based metrics
bandwidth
string
    Choices:
  • 1g
  • 10g
BW to apply metric to.
metric
integer
Specify metric
dead_interval
integer
Dead interval (seconds).
demand_circuit
boolean
    Choices:
  • no
  • yes
Interface functions as a demand circuit.
flood_reduction
boolean
    Choices:
  • no
  • yes
Enable flood reduction.
hello_interval
integer
Hello interval (seconds).
interface_type
string
    Choices:
  • nbma
  • p2mp
  • p2p
Specify type of interface
ipsec_sa
string
IPSec security association name
metric
integer
Metric applied to the interface.
mtu
integer
Maximum OSPF packet size
no_advertise_adjacency_segment
boolean
    Choices:
  • no
  • yes
Do not advertise an adjacency segment for this interface.
no_eligible_backup
boolean
    Choices:
  • no
  • yes
Not eligible to backup traffic from protected interfaces.
no_eligible_remote_backup
boolean
    Choices:
  • no
  • yes
Not eligible for Remote-LFA backup traffic from protected interfaces.
no_interface_state_traps
boolean
    Choices:
  • no
  • yes
Do not send interface state change traps.
no_neighbor_down_notification
boolean
    Choices:
  • no
  • yes
Don't inform other protocols about neighbor down events.
node_link_protection
string
Protect interface from both link and node faults.
poll_interval
integer
Poll interval (seconds).
priority
integer
Priority for the interface.
retransmit_interval
integer
Retransmit interval (seconds).
secondary
boolean
    Choices:
  • no
  • yes
Treat interface as secondary
te_metric
integer
Traffic engineering metric applied to the interface.
transit_delay
integer
Transit delay (seconds).
name
string / required
Name/Identifier of the interface.
router_id
string / required
The OSPFv3 router id.
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the Junos device by executing the command show protocols 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
  • parsed
  • gathered
  • rendered
The state the configuration should be left in.

Notes

Note

  • This module requires the netconf system service be enabled on the device being managed.

  • This module works with connection netconf. See the Junos OS Platform Options.

  • Tested against JunOS v18.4R1

Examples

# Using merged
#
# Before state
# ------------
#
# admin# show protocols ospf

- name: Merge Junos OSPF interfaces config
  junipernetworks.junos.junos_ospf_interfaces:
    config:
    - router_id: '10.200.16.75'
      name: 'ge-0/0/2.0'
      address_family:
        - afi: 'ipv4'
          processes:
            area:
              area_id: '0.0.0.2'
            priority: 3
            metric: 5
    state: merged

# After state
# -----------
#
# admin# show protocols ospf
# area 0.0.0.2 {
#     interface ge-0/0/2.0 {
#         metric 5;
#         priority 3;
#     }
# }

# Using replaced
#
# Before state
# ------------
#
# admin# show protocols ospf
# area 0.0.0.2 {
#     interface ge-0/0/2.0 {
#         metric 5;
#         priority 3;
#     }
# }
- name: Replace Junos OSPF interfaces config
  junipernetworks.junos.junos_ospf_interfaces:
   config:
     - router_id: '10.200.16.75'
       name: 'ge-0/0/2.0'
       address_family:
         - afi: 'ipv4'
           processes:
             area:
               area_id: '0.0.0.1'
             priority: 6
             metric: 6
   state: replaced

# After state
# -----------
#
# admin# show protocols ospf
# area 0.0.0.1 {
#     interface ge-0/0/2.0 {
#         metric 6;
#         priority 6;
#     }
# }

# Using overridden
#
# Before state
# ------------
#
# admin# show protocols ospf
# area 0.0.0.3 {
#     interface ge-0/0/3.0 {
#         metric 5;
#         priority 3;
#     }
# }
# area 0.0.0.2 {
#     interface ge-0/0/2.0 {
#         metric 5;
#         priority 3;
#     }
# }

- name: Override Junos OSPF interfaces config
  junipernetworks.junos.junos_ospf_interfaces:
  config:
    - router_id: '10.200.16.75'
      name: 'ge-0/0/1.0'
      address_family:
        - afi: 'ipv4'
          processes:
            area:
              area_id: '0.0.0.1'
            priority: 3
            metric: 5
  state: overridden

# After state
# -----------
#
# admin# show protocols ospf
# area 0.0.0.1 {
#     interface ge-0/0/1.0 {
#         metric 5;
#         priority 3;
#     }
# }

#
# Using deleted
#
# Before state
# ------------
#
# admin# show protocols ospf
# area 0.0.0.1 {
#     interface ge-0/0/1.0 {
#         metric 5;
#         priority 3;
#     }
# }

- name: Delete Junos OSPF interfaces config
  junipernetworks.junos.junos_ospf_interfaces:
    config:
      - router_id: '10.200.16.75'
        name: 'ge-0/0/1.0'
    state: deleted

# After state
# -----------
#
# admin# show protocols ospf
# Using gathered
#
# Before state
# ------------
#
# admin# show protocols ospf
# area 0.0.0.3 {
#     interface ge-0/0/3.0 {
#         metric 5;
#         priority 3;
#     }
# }
# area 0.0.0.2 {
#     interface ge-0/0/2.0 {
#         metric 5;
#         priority 3;
#     }
# }

- name: Gather Junos OSPF interfaces config
  junipernetworks.junos.junos_ospf_interfaces:
    config:
    state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "gathered": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "processes": {
#                         "area": {
#                             "area_id": "0.0.0.3"
#                         },
#                         "metric": 5,
#                         "priority": 3
#                     }
#                 }
#             ],
#             "name": "ge-0/0/3.0",
#             "router_id": "10.200.16.75"
#         },
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "processes": {
#                         "area": {
#                             "area_id": "0.0.0.2"
#                         },
#                         "metric": 5,
#                         "priority": 3
#                     }
#                 }
#             ],
#             "name": "ge-0/0/2.0",
#             "router_id": "10.200.16.75"
#         }
#     ]
#
# Using rendered
#
#
- name: Render the commands for provided  configuration
  junipernetworks.junos.junos_ospf_interfaces:
    config:
    - router_id: '10.200.16.75'
      name: 'ge-0/0/2.0'
      address_family:
        - afi: 'ipv4'
          processes:
            area:
              area_id: '0.0.0.2'
            priority: 3
            metric: 5
    state: rendered

#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "rendered": "
# <nc:protocols
#     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
#     <nc:ospf>
#         <nc:area>
#             <nc:name>0.0.0.2</nc:name>
#             <nc:interface>
#                 <nc:name>ge-0/0/2.0</nc:name>
#                 <nc:priority>3</nc:priority>
#                 <nc:metric>5</nc:metric>
#             </nc:interface>
#         </nc:area>
#     </nc:ospf>
# </nc:protocols>"
#
# Using parsed
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
#     <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
#         <protocols>
#             <ospf>
#                 <area>
#                     <name>0.0.0.2</name>
#                     <stub>
#                         <default-metric>200</default-metric>
#                     </stub>
#                     <interface>
#                         <name>ge-0/0/2.0</name>
#                         <metric>5</metric>
#                         <priority>3</priority>
#                     </interface>
#                 </area>
#             </ospf>
#         </protocols>
#         <routing-options>
#             <router-id>10.200.16.75</router-id>
#         </routing-options>
#     </configuration>
# </rpc-reply>


- name: Parsed the device configuration to get output commands
  junipernetworks.junos.junos_ospf_interfaces:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": [
#         {
#             "address_family": [
#                 {
#                     "afi": "ipv4",
#                     "processes": {
#                         "area": {
#                             "area_id": "0.0.0.2"
#                         },
#                         "metric": 5,
#                         "priority": 3
#                     }
#                 }
#             ],
#             "name": "ge-0/0/2.0",
#             "router_id": "10.200.16.75"
#         }
#     ]
#

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:
['<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> <nc:ospf> <nc:area> <nc:name>0.0.0.3</nc:name> <nc:interface> <nc:name>ge-0/0/3.0</nc:name> <nc:priority>3</nc:priority> <nc:metric>5</nc:metric> </nc:interface> </nc:area> <nc:area> <nc:name>0.0.0.2</nc:name> <nc:interface> <nc:name>ge-0/0/2.0</nc:name> <nc:priority>3</nc:priority> <nc:metric>5</nc:metric> </nc:interface> </nc:area> </nc:ospf> </nc:protocols>", " <nc:routing-options xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> <nc:router-id>10.200.16.75</nc:router-id> <nc:router-id>10.200.16.75</nc:router-id> </nc:routing-options>', 'xml 2', 'xml 3']


Authors

  • Rohit Thakur (@rohitthakur2590)