Skip to content

Instantly share code, notes, and snippets.

@rohitthakur2590
Created April 1, 2020 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohitthakur2590/a489f305b489b27ebda1c9282a67f7c8 to your computer and use it in GitHub Desktop.
Save rohitthakur2590/a489f305b489b27ebda1c9282a67f7c8 to your computer and use it in GitHub Desktop.
+++++++++++++++++++++++++ Playbook +++++++++++++++++++++++++++++++++++++
- hosts: vyos
gather_facts: false
connection: network_cli
collections:
- vyos.vyos
tasks:
- name: ospf_global
vyos.vyos.vyos_ospf_global: &id001
config:
- afi: 'ipv4'
log_adjacency_changes: 'detail'
max_metric:
router_lsa:
administrative: true
on_shutdown: 10
on_startup: 10
default_information:
originate:
always: true
metric: 10
metric_type: 2
route_map: 'ingress'
mpls_te:
enabled: true
router_address: '9.9.9.9'
auto_cost:
reference_bandwidth: 2
neighbor:
- neighbor_id: '7.7.7.7'
poll_interval: 10
priority: 2
redistribute:
- route_type: 'bgp'
metric: 10
metric_type: 2
# route_map: 'ingress'
passive_interface:
- 'eth1'
- 'eth2'
- 'eth3'
parameters:
router_id: '22.22.22.22'
opaque_lsa: true
rfc1583_compatibility: true
abr_type: 'cisco'
ospf_area:
- area: '2'
area_type:
normal: true
authentication: "plaintext-password"
shortcut: 'enable'
- area: '3'
area_type:
nssa:
default_cost: 30
- area: '4'
area_type:
stub:
default_cost: 20
network:
- address: '11.11.13.0/24'
- address: '11.11.14.0/24'
- address: '11.11.15.0/24'
- address: '11.11.16.0/24'
range:
- address: '1.1.2.0/24'
cost: 10
state: merged
++++++++++++++++++++++++++++++++++++++++++++ OUTPUT ++++++++++++++++++++++++++++++++++++++++++++++++++
"after": [
{
"afi": "ipv4",
"auto_cost": {
"reference_bandwidth": 2
},
"default_information": {
"originate": {
"always": true,
"metric": 10,
"metric_type": 2,
"route_map": "ingress"
}
},
"log_adjacency_changes": "detail",
"max_metric": {
"router_lsa": {
"administrative": true,
"on_shutdown": 10,
"on_startup": 10
}
},
"mpls_te": {
"enabled": true,
"router_address": "9.9.9.9"
},
"neighbor": [
{
"neighbor_id": "7.7.7.7",
"poll_interval": 10,
"priority": 2
}
],
"ospf_area": [
{
"area": "2",
"area_type": {
"normal": true
},
"authentication": "plaintext-password",
"shortcut": "enable"
},
{
"area": "3",
"area_type": {
"nssa": {
"default_cost": 30
},
"stub": {
"default_cost": 30
}
}
},
{
"area": "4",
"area_type": {
"nssa": {
"default_cost": 20
},
"stub": {
"default_cost": 20
}
},
"network": [
{
"address": "11.11.13.0/24"
},
{
"address": "11.11.14.0/24"
},
{
"address": "11.11.15.0/24"
},
{
"address": "11.11.16.0/24"
}
],
"range": [
{
"address": "1.1.2.0/24",
"cost": 10
}
]
}
],
"parameters": {
"abr_type": "cisco",
"opaque_lsa": true,
"rfc1583_compatibility": true,
"router_id": "22.22.22.22"
},
"passive_interface": [
"eth2",
"eth3",
"eth1"
],
"redistribute": [
{
"metric": 10,
"metric_type": 2,
"route_type": "bgp"
}
]
}
],
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"before": [],
"changed": true,
"commands": [
"set protocols ospf mpls-te enable",
"set protocols ospf mpls-te router-address '9.9.9.9'",
"set protocols ospf redistribute bgp",
"set protocols ospf redistribute bgp metric-type 2",
"set protocols ospf redistribute bgp metric 10",
"set protocols ospf auto-cost reference-bandwidth '2'",
"set protocols ospf parameters router-id '22.22.22.22'",
"set protocols ospf parameters opaque-lsa",
"set protocols ospf parameters abr-type 'cisco'",
"set protocols ospf parameters rfc1583-compatibility",
"set protocols ospf default-information originate metric-type 2",
"set protocols ospf default-information originate always",
"set protocols ospf default-information originate metric 10",
"set protocols ospf default-information originate route-map ingress",
"set protocols ospf max-metric router-lsa on-shutdown 10",
"set protocols ospf max-metric router-lsa administrative",
"set protocols ospf max-metric router-lsa on-startup 10",
"set protocols ospf log-adjacency-changes 'detail'",
"set protocols ospf area 2 authentication plaintext-password",
"set protocols ospf area '2'",
"set protocols ospf area 2 shortcut enable",
"set protocols ospf area 2 area-type normal",
"set protocols ospf area '3'",
"set protocols ospf area 3 area-type nssa default-cost 30",
"set protocols ospf area 4 range 1.1.2.0/24 cost 10",
"set protocols ospf area 4 range 1.1.2.0/24",
"set protocols ospf area '4'",
"set protocols ospf area 4 network 11.11.13.0/24",
"set protocols ospf area 4 network 11.11.14.0/24",
"set protocols ospf area 4 network 11.11.15.0/24",
"set protocols ospf area 4 network 11.11.16.0/24",
"set protocols ospf area 4 area-type stub default-cost 20",
"set protocols ospf neighbor 7.7.7.7 priority 2",
"set protocols ospf neighbor 7.7.7.7 poll-interval 10",
"set protocols ospf neighbor 7.7.7.7",
"set protocols ospf passive-interface eth1",
"set protocols ospf passive-interface eth2",
"set protocols ospf passive-interface eth3"
],
"invocation": {
"module_args": {
"config": [
{
"afi": "ipv4",
"auto_cost": {
"reference_bandwidth": 2
},
"default_information": {
"originate": {
"always": true,
"metric": 10,
"metric_type": 2,
"route_map": "ingress"
}
},
"default_metric": null,
"distance": null,
"log_adjacency_changes": "detail",
"max_metric": {
"router_lsa": {
"administrative": true,
"on_shutdown": 10,
"on_startup": 10
}
},
"mpls_te": {
"enabled": true,
"router_address": "9.9.9.9"
},
"neighbor": [
{
"neighbor_id": "7.7.7.7",
"poll_interval": 10,
"priority": 2
}
],
"ospf_area": [
{
"area": "2",
"area_type": {
"normal": true,
"nssa": null,
"stub": null
},
"authentication": "plaintext-password",
"export_list": null,
"import_list": null,
"network": null,
"range": null,
"shortcut": "enable",
"virtual_link": null
},
{
"area": "3",
"area_type": {
"normal": null,
"nssa": {
"default_cost": 30,
"no_summary": null,
"translate": null
},
"stub": null
},
"authentication": null,
"export_list": null,
"import_list": null,
"network": null,
"range": null,
"shortcut": null,
"virtual_link": null
},
{
"area": "4",
"area_type": {
"normal": null,
"nssa": null,
"stub": {
"default_cost": 20,
"no_summary": null
}
},
"authentication": null,
"export_list": null,
"import_list": null,
"network": [
{
"address": "11.11.13.0/24"
},
{
"address": "11.11.14.0/24"
},
{
"address": "11.11.15.0/24"
},
{
"address": "11.11.16.0/24"
}
],
"range": [
{
"address": "1.1.2.0/24",
"advertise": null,
"cost": 10,
"not_advertise": null,
"substitute": null
}
],
"shortcut": null,
"virtual_link": null
}
],
"parameters": {
"abr_type": "cisco",
"opaque_lsa": true,
"rfc1583_compatibility": true,
"router_id": "22.22.22.22"
},
"passive_interface": [
"eth1",
"eth2",
"eth3"
],
"passive_interface_exclude": null,
"redistribute": [
{
"metric": 10,
"metric_type": 2,
"route_map": null,
"route_type": "bgp"
}
],
"route_map": null,
"timers": null
}
],
"state": "merged"
}
}
}
+++++++++++++++++++++++++++++++++++++++++++++ MODEL +++++++++++++++++++++++++++++++++++++++++++++++++
Model
---
GENERATOR_VERSION: '1.0'
ANSIBLE_METADATA: |
{
'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'network'
}
NETWORK_OS: vyos
RESOURCE: ospf_global
COPYRIGHT: Copyright 2019 Red Hat
DOCUMENTATION: |
module: vyos_ospf_global
version_added: 2.10
short_description: Manages attributes of OSPF routes on VyOS network devices.
description: This module manages attributes of OSPF routes on VyOS network devices.
author: Rohit Thakur (@rohitthakur2590)
options:
config:
description: A provided OSPF route configuration.
type: list
elements: dict
suboptions:
afi:
description:
- Specifies the type of ospf route.
type: str
choices: ['ipv4', 'ipv6']
required: True
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
advertise:
description: Advertise this range.
type: bool
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
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
export_list:
description: Name of export-list.
type: str
import_list:
description: Name of import-list.
type: str
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 "after": [
{
"afi": "ipv4",
"auto_cost": {
"reference_bandwidth": 2
},
"default_information": {
"originate": {
"always": true,
"metric": 10,
"metric_type": 2,
"route_map": "ingress"
}
},
"log_adjacency_changes": "detail",
"max_metric": {
"router_lsa": {
"administrative": true,
"on_shutdown": 10,
"on_startup": 10
}
},
"mpls_te": {
"enabled": true,
"router_address": "9.9.9.9"
},
"neighbor": [
{
"neighbor_id": "7.7.7.7",
"poll_interval": 10,
"priority": 2
}
],
"ospf_area": [
{
"area": "2",
"area_type": {
"normal": true
},
"authentication": "plaintext-password",
"shortcut": "enable"
},
{
"area": "3",
"area_type": {
"nssa": {
"default_cost": 30
},
"stub": {
"default_cost": 30
}
}
},
{
"area": "4",
"area_type": {
"nssa": {
"default_cost": 20
},
"stub": {
"default_cost": 20
}
},
"network": [
{
"address": "11.11.13.0/24"
},
{
"address": "11.11.14.0/24"
},
{
"address": "11.11.15.0/24"
},
{
"address": "11.11.16.0/24"
}
],
"range": [
{
"address": "1.1.2.0/24",
"cost": 10
}
]
}
],
"parameters": {
"abr_type": "cisco",
"opaque_lsa": true,
"rfc1583_compatibility": true,
"router_id": "22.22.22.22"
},
"passive_interface": [
"eth2",
"eth3",
"eth1"
],
"redistribute": [
{
"metric": 10,
"metric_type": 2,
"route_type": "bgp"
}
]
}
],
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"before": [],
"changed": true,
"commands": [
"set protocols ospf mpls-te enable",
"set protocols ospf mpls-te router-address '9.9.9.9'",
"set protocols ospf redistribute bgp",
"set protocols ospf redistribute bgp metric-type 2",
"set protocols ospf redistribute bgp metric 10",
"set protocols ospf auto-cost reference-bandwidth '2'",
"set protocols ospf parameters router-id '22.22.22.22'",
"set protocols ospf parameters opaque-lsa",
"set protocols ospf parameters abr-type 'cisco'",
"set protocols ospf parameters rfc1583-compatibility",
"set protocols ospf default-information originate metric-type 2",
"set protocols ospf default-information originate always",
"set protocols ospf default-information originate metric 10",
"set protocols ospf default-information originate route-map ingress",
"set protocols ospf max-metric router-lsa on-shutdown 10",
"set protocols ospf max-metric router-lsa administrative",
"set protocols ospf max-metric router-lsa on-startup 10",
"set protocols ospf log-adjacency-changes 'detail'",
"set protocols ospf area 2 authentication plaintext-password",
"set protocols ospf area '2'",
"set protocols ospf area 2 shortcut enable",
"set protocols ospf area 2 area-type normal",
"set protocols ospf area '3'",
"set protocols ospf area 3 area-type nssa default-cost 30",
"set protocols ospf area 4 range 1.1.2.0/24 cost 10",
"set protocols ospf area 4 range 1.1.2.0/24",
"set protocols ospf area '4'",
"set protocols ospf area 4 network 11.11.13.0/24",
"set protocols ospf area 4 network 11.11.14.0/24",
"set protocols ospf area 4 network 11.11.15.0/24",
"set protocols ospf area 4 network 11.11.16.0/24",
"set protocols ospf area 4 area-type stub default-cost 20",
"set protocols ospf neighbor 7.7.7.7 priority 2",
"set protocols ospf neighbor 7.7.7.7 poll-interval 10",
"set protocols ospf neighbor 7.7.7.7",
"set protocols ospf passive-interface eth1",
"set protocols ospf passive-interface eth2",
"set protocols ospf passive-interface eth3"
],
"invocation": {
"module_args": {
"config": [
{
"afi": "ipv4",
"auto_cost": {
"reference_bandwidth": 2
},
"default_information": {
"originate": {
"always": true,
"metric": 10,
"metric_type": 2,
"route_map": "ingress"
}
},
"default_metric": null,
"distance": null,
"log_adjacency_changes": "detail",
"max_metric": {
"router_lsa": {
"administrative": true,
"on_shutdown": 10,
"on_startup": 10
}
},
"mpls_te": {
"enabled": true,
"router_address": "9.9.9.9"
},
"neighbor": [
{
"neighbor_id": "7.7.7.7",
"poll_interval": 10,
"priority": 2
}
],
"ospf_area": [
{
"area": "2",
"area_type": {
"normal": true,
"nssa": null,
"stub": null
},
"authentication": "plaintext-password",
"export_list": null,
"import_list": null,
"network": null,
"range": null,
"shortcut": "enable",
"virtual_link": null
},
{
"area": "3",
"area_type": {
"normal": null,
"nssa": {
"default_cost": 30,
"no_summary": null,
"translate": null
},
"stub": null
},
"authentication": null,
"export_list": null,
"import_list": null,
"network": null,
"range": null,
"shortcut": null,
"virtual_link": null
},
{
"area": "4",
"area_type": {
"normal": null,
"nssa": null,
"stub": {
"default_cost": 20,
"no_summary": null
}
},
"authentication": null,
"export_list": null,
"import_list": null,
"network": [
{
"address": "11.11.13.0/24"
},
{
"address": "11.11.14.0/24"
},
{
"address": "11.11.15.0/24"
},
{
"address": "11.11.16.0/24"
}
],
"range": [
{
"address": "1.1.2.0/24",
"advertise": null,
"cost": 10,
"not_advertise": null,
"substitute": null
}
],
"shortcut": null,
"virtual_link": null
}
],
"parameters": {
"abr_type": "cisco",
"opaque_lsa": true,
"rfc1583_compatibility": true,
"router_id": "22.22.22.22"
},
"passive_interface": [
"eth1",
"eth2",
"eth3"
],
"passive_interface_exclude": null,
"redistribute": [
{
"metric": 10,
"metric_type": 2,
"route_map": null,
"route_type": "bgp"
}
],
"route_map": null,
"timers": null
}
],
"state": "merged"
}
}
}
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', 'ripng']
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
- overridden
- deleted
- parsed
- gathered
- rendered
default: merged
EXAMPLES:
- merged_example_01.txt
- replaced_example_01.txt
- overridden_example_01.txt
- rendered_example_01.txt
- parsed_example_01.txt
- gathered_example_01.txt
- deleted_example_01.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment