Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F119898746
vyos_ospfv2.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
44 KB
Referenced Files
None
Subscribers
None
vyos_ospfv2.py
View Options
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#############################################
# WARNING #
#############################################
#
# This file is auto generated by the resource
# module builder playbook.
#
# Do not edit this file manually.
#
# Changes to this file will be over written
# by the resource module builder.
#
# Changes should be made in the model used to
# generate this file or in the resource module
# builder template.
#
#############################################
"""
The module file for vyos_ospfv2
"""
from
__future__
import
absolute_import
,
division
,
print_function
__metaclass__
=
type
ANSIBLE_METADATA
=
{
'metadata_version'
:
'1.1'
,
'status'
:
[
'preview'
],
'supported_by'
:
'network'
}
DOCUMENTATION
=
"""
---
module: vyos_ospfv2
version_added: 2.10
short_description: Manages attributes of OSPF IPv4 routes on VyOS network devices.
description: This module manages attributes of OSPF IPv4 routes on VyOS network devices.
author: Rohit Thakur (@rohitthakur2590)
options:
config:
description: A provided OSPF route configuration.
type: list
elements: dict
suboptions:
ospf_area:
description: OSPF area.
type: list
elements: dict
suboptions:
area:
description: Configured to discard packets.
type: str
area_type:
description: Area type.
type: dict
suboptions:
normal:
description: Normal OSPF area.
type: bool
nssa:
description: Nssa OSPF area.
type: dict
suboptions:
default_cost:
description: Summary-default cost of nssa area.
type: int
no_summary:
description: Do not inject inter-area routes into stub.
type: bool
translate:
description: Nssa-abr.
type: str
choices: ['always', 'candidate', 'never']
stub:
description: Stub OSPF area.
type: dict
suboptions:
default_cost:
description: Summary-default cost of stub area.
type: int
no_summary:
description: Do not inject inter-area routes into stub.
type: bool
authentication:
description: OSPF area authentication type.
type: str
choices: ['plaintext-password', 'md5']
network:
description: OSPF network.
type: list
elements: dict
suboptions:
address:
required: True
description: OSPF IPv4 network address.
type: str
range:
description: Summarize routes matching prefix (border routers only).
type: list
elements: dict
suboptions:
address:
description: border router IPv4 address.
type: str
cost:
description: Metric for this range.
type: int
not_advertise:
description: Don't advertise this range.
type: bool
substitute:
description: Announce area range (IPv4 address) as another prefix.
type: str
shortcut:
description: Area's shortcut mode.
type: str
choices: ['default', 'disable', 'enable']
virtual_link:
description: Virtual link address.
type: list
elements: dict
suboptions:
address:
description: virtual link address.
type: str
authentication:
description: OSPF area authentication type.
type: dict
suboptions:
md5:
description: MD5 key id based authentication.
type: dict
suboptions:
key_id:
description: MD5 key id.
type: int
md5_key:
description: MD5 key.
type: str
plaintext_password:
description: Plain text password.
type: str
dead_interval:
description: Interval after which a neighbor is declared dead.
type: int
hello_interval:
description: Interval between hello packets.
type: int
retransmit_interval:
description: Interval between retransmitting lost link state advertisements.
type: int
transmit_delay:
description: Link state transmit delay.
type: int
log_adjacency_changes:
description: Log changes in adjacency state.
type: str
choices: ['detail']
max_metric:
description: OSPF maximum/infinite-distance metric.
type: dict
suboptions:
router_lsa:
description: Advertise own Router-LSA with infinite distance (stub router).
type: dict
suboptions:
administrative:
description: Administratively apply, for an indefinite period.
type: bool
on_shutdown:
description: Time to advertise self as stub-router.
type: int
on_startup:
description: Time to advertise self as stub-router
type: int
auto_cost:
description: Calculate OSPF interface cost according to bandwidth.
type: dict
suboptions:
reference_bandwidth:
description: Reference bandwidth cost in Mbits/sec.
type: int
default_information:
description: Control distribution of default information.
type: dict
suboptions:
originate:
description: Distribute a default route.
type: dict
suboptions:
always:
description: Always advertise default route.
type: bool
metric:
description: OSPF default metric.
type: int
metric_type:
description: OSPF Metric types for default routes.
type: int
route_map:
description: Route map references.
type: str
default_metric:
description: Metric of redistributed routes
type: int
distance:
description: Administrative distance.
type: dict
suboptions:
global:
description: Global OSPF administrative distance.
type: int
ospf:
description: OSPF administrative distance.
type: dict
suboptions:
external:
description: Distance for external routes.
type: int
inter_area:
description: Distance for inter-area routes.
type: int
intra_area:
description: Distance for intra-area routes.
type: int
mpls_te:
description: MultiProtocol Label Switching-Traffic Engineering (MPLS-TE) parameters.
type: dict
suboptions:
enabled:
description: Enable MPLS-TE functionality.
type: bool
router_address:
description: Stable IP address of the advertising router.
type: str
neighbor:
description: Neighbor IP address.
type: list
elements: dict
suboptions:
neighbor_id:
description: Identity (number/IP address) of neighbor.
type: str
poll_interval:
description: Seconds between dead neighbor polling interval.
type: int
priority:
description: Neighbor priority.
type: int
parameters:
descriptions: OSPF specific parameters.
type: dict
suboptions:
abr_type:
description: OSPF ABR Type.
type: str
choices: ['cisco', 'ibm', 'shortcut', 'standard']
opaque_lsa:
description: Enable the Opaque-LSA capability (rfc2370).
type: bool
rfc1583_compatibility:
description: Enable rfc1583 criteria for handling AS external routes.
type: bool
router_id:
description: Override the default router identifier.
type: str
passive_interface:
description: Suppress routing updates on an interface.
type: list
passive_interface_exclude:
description: Interface to exclude when using passive-interface default.
type: list
redistribute:
description: Redistribute information from another routing protocol.
type: list
elements: dict
suboptions:
route_type:
description: Route type to redistribute.
type: str
choices: ['bgp', 'connected', 'kernel', 'rip', 'static']
metric:
description: Metric for redistribution routes.
type: int
metric_type:
description: OSPF Metric types.
type: int
route_map:
description: Route map references.
type: str
route_map:
description: Filter routes installed in local route map.
type: list
timers:
description: Adjust routing timers.
type: dict
suboptions:
refresh:
description: Adjust refresh parameters.
type: dict
suboptions:
timers:
description: refresh timer.
type: int
throttle:
description: Throttling adaptive timers.
type: dict
suboptions:
spf:
description: OSPF SPF timers.
type: dict
suboptions:
delay:
description: Delay (msec) from first change received till SPF calculation.
type: int
initial_holdtime:
description: Initial hold time(msec) between consecutive SPF calculations.
type: int
max_holdtime:
description: maximum hold time (sec).
type: int
state:
description:
- The state the configuration should be left in.
type: str
choices:
- merged
- replaced
- deleted
- parsed
- gathered
- rendered
default: merged
"""
EXAMPLES
=
"""
# Using merged
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
#
- name: Merge the provided configuration with the existing running configuration
vyos_ospf_routes:
config:
- afi: 'ipv4'
ospf_area:
- area: 0
network: 192.168.0.0/24
default_information:
originate:
always: true
metric: 2
metric_type: 10
log_adjacency_changes: "details"
parameters:
router_id: 10.1.1.1
redistribute:
- route_type: 'connected'
metric_type: 2
route_map: 'CONNECT'
- afi: 'ipv6'
ospf_area:
- area: 0.0.0.0
range: 2001:db8:1::/64
parameters:
router-id 192.168.1.1
redistribute:
- route_type: 'connected'
state: merged
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": []
#
# "commands": [
# "set interfaces ethernet eth1 firewall in name 'INBOUND'",
# "set protocols ospf area 0 network 192.168.0.0/24",
# "set protocols ospf default-information originate always",
# "set protocols ospf default-information originate metric 10",
# "set protocols ospf default-information originate metric-type 2",
# "set protocols ospf log-adjacency-changes",
# "set protocols ospf parameters router-id 10.1.1.1",
# "set protocols ospf redistribute connected metric-type 2",
# "set protocols ospf redistribute connected route-map CONNECT",
# "set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64,
# "set protocols ospfv3 parameters router-id 192.168.1.1,
# "set protocols ospfv3 redistribute connected
# ]
#
# "after": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
# Using replaced
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
#
- name: Replace the provided configuration with the existing running configuration
vyos_ospf_routes:
config:
- afi: 'ipv4'
ospf_area:
- area: 0
network: 192.168.0.0/24
area_type:
normal: True
default_information:
originate:
always: true
metric: 2
metric_type: 10
log_adjacency_changes: "details"
parameters:
router_id: 10.1.1.1
redistribute:
- route_type: 'static'
metric_type: 2
route_map: 'STATIC'
- afi: 'ipv6'
ospf_area:
- area: 0.0.0.0
range: 2001:db8:1::/64
parameters:
router-id 192.168.1.1
redistribute:
- route_type: 'connected'
state: replaced
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# "commands": [
# "delete protocols ospf redistribute connected",
# "set protocols ospf area 0 area_type normal",
# "set protocols ospf redistribute static metric-type 2",
# "set protocols ospf redistribute static route-map CONNECT"
# ]
#
# "after": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "area_type":
# {
# normal: true
# }
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "static",
# "metric_type": 2
# "route_map": "STATIC"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connected",
# }
# ]
# }
# ]
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute static metric-type 2
# set protocols ospf redistribute static route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:2::/64
# set protocols ospfv3 parameters router-id 192.168.2.1
# set protocols ospfv3 redistribute connected
# Using replaced
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
#
- name: Replace the provided configuration with the existing running configuration
vyos_ospf_routes:
config:
- afi: 'ipv4'
ospf_area:
- area: 0
network: 192.168.0.0/24
area_type:
normal: True
default_information:
originate:
always: true
metric: 2
metric_type: 10
log_adjacency_changes: "details"
parameters:
router_id: 10.1.1.1
redistribute:
- route_type: 'static'
metric_type: 2
route_map: 'STATIC'
- afi: 'ipv6'
ospf_area:
- area: 0.0.0.0
range: 2001:db8:1::/64
parameters:
router-id 192.168.1.1
redistribute:
- route_type: 'connected'
state: replaced
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# "commands": [
# "delete protocols ospf redistribute connected",
# "set protocols ospf area 0 area_type normal",
# "set protocols ospf redistribute static metric-type 2",
# "set protocols ospf redistribute static route-map CONNECT"
# ]
#
# "after": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "area_type":
# {
# normal: true
# }
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "static",
# "metric_type": 2
# "route_map": "STATIC"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connected",
# }
# ]
# }
# ]
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute static metric-type 2
# set protocols ospf redistribute static route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:2::/64
# set protocols ospfv3 parameters router-id 192.168.2.1
# set protocols ospfv3 redistribute connected
# Using replaced
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
#
- name: Replace the provided configuration with the existing running configuration
vyos_ospf_routes:
config:
- afi: 'ipv4'
ospf_area:
- area: 0
network: 192.168.0.0/24
area_type:
normal: True
default_information:
originate:
always: true
metric: 2
metric_type: 10
log_adjacency_changes: "details"
parameters:
router_id: 10.1.1.1
redistribute:
- route_type: 'static'
metric_type: 2
route_map: 'STATIC'
- afi: 'ipv6'
ospf_area:
- area: 0.0.0.0
range: 2001:db8:1::/64
parameters:
router-id 192.168.1.1
redistribute:
- route_type: 'connected'
state: replaced
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# "commands": [
# "delete protocols ospf redistribute connected",
# "set protocols ospf area 0 area_type normal",
# "set protocols ospf redistribute static metric-type 2",
# "set protocols ospf redistribute static route-map CONNECT"
# ]
#
# "after": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "area_type":
# {
# normal: true
# }
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "static",
# "metric_type": 2
# "route_map": "STATIC"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connected",
# }
# ]
# }
# ]
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute static metric-type 2
# set protocols ospf redistribute static route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:2::/64
# set protocols ospfv3 parameters router-id 192.168.2.1
# set protocols ospfv3 redistribute connected
# Using replaced
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
#
- name: Replace the provided configuration with the existing running configuration
vyos_ospf_routes:
config:
- afi: 'ipv4'
ospf_area:
- area: 0
network: 192.168.0.0/24
area_type:
normal: True
default_information:
originate:
always: true
metric: 2
metric_type: 10
log_adjacency_changes: "details"
parameters:
router_id: 10.1.1.1
redistribute:
- route_type: 'static'
metric_type: 2
route_map: 'STATIC'
- afi: 'ipv6'
ospf_area:
- area: 0.0.0.0
range: 2001:db8:1::/64
parameters:
router-id 192.168.1.1
redistribute:
- route_type: 'connected'
state: replaced
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# "commands": [
# "delete protocols ospf redistribute connected",
# "set protocols ospf area 0 area_type normal",
# "set protocols ospf redistribute static metric-type 2",
# "set protocols ospf redistribute static route-map CONNECT"
# ]
#
# "after": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "area_type":
# {
# normal: true
# }
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "static",
# "metric_type": 2
# "route_map": "STATIC"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connected",
# }
# ]
# }
# ]
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute static metric-type 2
# set protocols ospf redistribute static route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:2::/64
# set protocols ospfv3 parameters router-id 192.168.2.1
# set protocols ospfv3 redistribute connected
# Using deleted
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 0 network 192.168.0.0/24
# set protocols ospf default-information originate always
# set protocols ospf default-information originate metric 10
# set protocols ospf default-information originate metric-type 2
# set protocols ospf log-adjacency-changes details
# set protocols ospf parameters router-id 10.1.1.1
# set protocols ospf redistribute connected metric-type 2
# set protocols ospf redistribute connected route-map CONNECT
# set protocols ospfv3 area 0.0.0.0 range 2001:db8:1::/64
# set protocols ospfv3 parameters router-id 192.168.1.1
# set protocols ospfv3 redistribute connected
#
- name: Delete all the configuration
vyos_ospf_routes:
config:
state: deleted
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": [
# {
# {
# "afi": "ipv4",
# "ospf_area":[
# {
# "area": "0",
# "network": "192.168.0.0/24"
# }
# ],
# "default_information":
# {
# "originate":
# {
# always: true,
# metric: 2,
# metric_type: 10
# }
# },
# "log_adjacency_changes": "details"
# "parameters":
# {
# "router_id": "10.1.1.1"
# },
# "redistribute":[
# {
# "route_type": "connetced",
# "metric_type": 2
# "route_map": "CONNECT"
# }
# ]
# },
# {
# "afi": "ipv6",
# "ospf_area":[
# {
# "area": "0.0.0.0",
# }
# ],
# "range": "2001:db8:1::/64",
# "parameters":
# {
# "router_id": "192.168.1.1"
# },
# "redistribute":
# [
# {
# "route_type": "connetced",
# }
# ]
# }
# ]
#
# "commands": [
# "delete protocols ospf",
# "delete protocols ospfv3",
# ]
#
# "after": []
#
# After state:
# -------------
#
# vyos@vyos:~$ show configuration commands| grep firewall
"""
RETURN
=
"""
before:
description: The configuration prior to the model invocation.
returned: always
sample: >
The configuration returned will always be in the same format
of the parameters above.
after:
description: The resulting configuration model invocation.
returned: when changed
sample: >
The configuration returned will always be in the same format
of the parameters above.
commands:
description: The set of commands pushed to the remote device.
returned: always
type: list
sample: ['command 1', 'command 2', 'command 3']
"""
from
ansible.module_utils.basic
import
AnsibleModule
from
ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv2.ospfv2
import
Ospfv2Args
from
ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospfv2.ospfv2
import
Ospfv2
def
main
():
"""
Main entry point for module execution
:returns: the result form module invocation
"""
required_if
=
[
(
"state"
,
"merged"
,
(
"config"
,)),
(
"state"
,
"replaced"
,
(
"config"
,)),
(
"state"
,
"parsed"
,
(
"running_config"
,)),
]
mutually_exclusive
=
[(
"config"
,
"running_config"
)]
module
=
AnsibleModule
(
argument_spec
=
Ospfv2Args
.
argument_spec
,
required_if
=
required_if
,
supports_check_mode
=
True
,
mutually_exclusive
=
mutually_exclusive
,
)
result
=
Ospfv2
(
module
)
.
execute_module
()
module
.
exit_json
(
**
result
)
if
__name__
==
'__main__'
:
main
()
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Thu, Nov 26, 8:30 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4734420
Default Alt Text
vyos_ospfv2.py (44 KB)
Attached To
Mode
R52 VyOS Ansible Collection
Attached
Detach File
Event Timeline
Log In to Comment