vyos.vyos.vyos_route_maps module – Route Map Resource Module.
Note
This module is part of the vyos.vyos collection (version 3.0.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install vyos.vyos
.
To use it in a playbook, specify: vyos.vyos.vyos_route_maps
.
New in vyos.vyos 2.3.0
Synopsis
This module manages route map configurations on devices running VYOS.
Parameters
Parameter |
Comments |
---|---|
A list of route-map configuration. |
|
Route Map rules. |
|
Action for matching routes Choices:
|
|
Route map name |
|
Continue on a different entry within the route-map. |
|
Description for the rule. |
|
Route parameters to match. |
|
Set as-path. |
|
BGP community attribute. |
|
BGP community-list to match |
|
BGP community-list to match Choices:
|
|
Extended community name. |
|
First hop interface of a route to match. |
|
IP prefix parameters to match. |
|
IP address of route to match. |
|
type of list Choices:
|
|
value of access-list and prefix list |
|
next hop prefix list. |
|
type of list Choices:
|
|
value of access-list and prefix list |
|
IP route-source to match |
|
type of list Choices:
|
|
value of access-list and prefix list |
|
IPv6 prefix parameters to match. |
|
IPv6 address of route to match. |
|
type of list Choices:
|
|
value of access-list and prefix list |
|
next-hop ipv6 address IPv6 <h:h:h:h:h:h:h:h>. |
|
BGP large-community-list to match. |
|
Route metric <1-65535>. |
|
bgp origin. Choices:
|
|
Peer IP address <x.x.x.x>. |
|
RPKI validation value. Choices:
|
|
Exit policy on matches. |
|
Rule number to goto on match <1-65535>. |
|
Next sequence number to goto on match. Choices:
|
|
Route map rule number <1-65535>. |
|
Route parameters. |
|
Border Gateway Protocol (BGP) aggregator attribute. |
|
AS number of an aggregation. |
|
IP address. |
|
BGP AS path exclude string ex “456 64500 45001” |
|
Prepend string for a Border Gateway Protocol (BGP) AS-path attribute. |
|
Border Gateway Protocol (BGP) atomic aggregate attribute. Choices:
|
|
ExtCommunity in format AS:value |
|
Border Gateway Protocol (BGP) communities matching a community-list. |
|
BGP communities with a community-list. |
|
Delete BGP communities matching the community-list. Choices:
|
|
Border Gateway Protocol (BGP) community attribute. |
|
Community in 4 octet AS:value format or it can be from local-AS, no-advertise,no-expert,internet,additive,none. |
|
Set route target value.ASN:nn_or_IP_address:nn VPN extended community. |
|
Set Site of Origin value. ASN:nn_or_IP_address:nn VPN extended community |
|
IP address. |
|
Nexthop IPv6 address. |
|
Global or Local Choices:
|
|
ipv6 address |
|
Set BGP large community value. |
|
Border Gateway Protocol (BGP) local preference attribute.Example <0-4294967295>. |
|
Destination routing protocol metric. Example <0-4294967295>. |
|
Open Shortest Path First (OSPF) external metric-type. Choices:
|
|
Set bgp origin. Choices:
|
|
Border Gateway Protocol (BGP) originator ID attribute. Originator IP address. |
|
Source address for route. Example <x.x.x.x> IP address. |
|
Tag value for routing protocol. Example <1-65535> |
|
Border Gateway Protocol (BGP) weight attribute. Example <0-4294967295> |
|
Route map name. |
|
This option is used only with state parsed. The value of this option should be the output received from the VYOS device by executing the command show configuration commands | grep route-map. The state parsed reads the configuration from |
|
The state the configuration should be left in. Choices:
|
Notes
Note
Tested against vyos 1.2.
This module works with connection
network_cli
.
Examples
# Using merged
# Before state
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# vyos@vyos:~$
- name: Merge the provided configuration with the existing running configuration
register: result
vyos.vyos.vyos_route_maps: &id001
config:
- route_map: test1
entries:
- sequence: 1
description: "test"
action: permit
continue: 2
on_match:
next: True
- route_map: test3
entries:
- sequence: 1
action: permit
match:
rpki: invalid
metric: 1
peer: 192.0.2.32
set:
local_preference: 4
metric: 5
metric_type: "type-1"
origin: egp
originator_id: 192.0.2.34
tag: 5
weight: 4
state: merged
# After State
# vyos@vyos:~$ show configuration commands | match "set policy route-maps"
# set policy route-map test1 rule 1 description test
# set policy route-map test1 rule 1 action permit
# set policy route-map test1 rule 1 continue 2
# set policy route-map test1 rule 1 on-match next
# set policy route-map test3 rule 1 action permit
# set policy route-map test3 rule 1 set local-preference 4
# set policy route-map test3 rule 1 set metric 5
# set policy route-map test3 rule 1 set metric-type type-1
# set policy route-map test3 rule 1 set origin egp
# set policy route-map test3 rule 1 set originator-id 192.0.2.34
# set policy route-map test3 rule 1 set tag 5
# set policy route-map test3 rule 1 set weight 4
# set policy route-map test3 rule 1 match metric 1
# set policy route-map test3 rule 1 match peer 192.0.2.32
# set policy route-map test3 rule 1 match rpki invalid
# "after": [
# {
# "entries": [
# {
# "action": "permit",
# "continue_sequence": 2,
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# }
# ],
# "route_map": "test1"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 1,
# "peer": "192.0.2.32",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "local_preference": "4",
# "metric": "5",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "5",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "before": [],
# "changed": true,
# "commands": [
# "set policy route-map test1 rule 1 description test",
# "set policy route-map test1 rule 1 action permit",
# "set policy route-map test1 rule 1 continue 2",
# "set policy route-map test1 rule 1 on-match next",
# "set policy route-map test3 rule 1 action permit",
# "set policy route-map test3 rule 1 set local-preference 4",
# "set policy route-map test3 rule 1 set metric 5",
# "set policy route-map test3 rule 1 set metric-type type-1",
# "set policy route-map test3 rule 1 set origin egp",
# "set policy route-map test3 rule 1 set originator-id 192.0.2.34",
# "set policy route-map test3 rule 1 set tag 5",
# "set policy route-map test3 rule 1 set weight 4",
# "set policy route-map test3 rule 1 match metric 1",
# "set policy route-map test3 rule 1 match peer 192.0.2.32",
# "set policy route-map test3 rule 1 match rpki invalid"
# ],
# Using replaced:
# --------------
# Before state:
# vyos@vyos:~$ show configuration commands | match "set route-map policy"
# set policy route-map test2 rule 1 action 'permit'
# set policy route-map test2 rule 1 description 'test'
# set policy route-map test2 rule 1 on-match next
# set policy route-map test2 rule 2 action 'permit'
# set policy route-map test2 rule 2 on-match goto '4'
# set policy route-map test3 rule 1 action 'permit'
# set policy route-map test3 rule 1 match metric '1'
# set policy route-map test3 rule 1 match peer '192.0.2.32'
# set policy route-map test3 rule 1 match rpki 'invalid'
# set policy route-map test3 rule 1 set community 'internet'
# set policy route-map test3 rule 1 set ip-next-hop '192.0.2.33'
# set policy route-map test3 rule 1 set local-preference '4'
# set policy route-map test3 rule 1 set metric '5'
# set policy route-map test3 rule 1 set metric-type 'type-1'
# set policy route-map test3 rule 1 set origin 'egp'
# set policy route-map test3 rule 1 set originator-id '192.0.2.34'
# set policy route-map test3 rule 1 set tag '5'
# set policy route-map test3 rule 1 set weight '4'
#
# - name: Replace the provided configuration with the existing running configuration
# register: result
# vyos.vyos.vyos_route_maps: &id001
# config:
# - route_map: test3
# entries:
# - sequence: 1
# action: permit
# match:
# rpki: invalid
# metric: 3
# peer: 192.0.2.35
# set:
# local_preference: 6
# metric: 4
# metric_type: "type-1"
# origin: egp
# originator_id: 192.0.2.34
# tag: 4
# weight: 4
# state: replaced
# After state:
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# set policy route-map test3 rule 1 set local-preference 6
# set policy route-map test3 rule 1 set metric 4
# set policy route-map test3 rule 1 set tag 4
# set policy route-map test3 rule 1 match metric 3
# set policy route-map test3 rule 1 match peer 192.0.2.35
# vyos@vyos:~$
#
#
# Module Execution:
#
# "after": [
# {
# "entries": [
# {
# "action": "permit",
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# },
# {
# "action": "permit",
# "on_match": {
# "goto": 4
# },
# "sequence": 2
# }
# ],
# "route_map": "test2"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 3,
# "peer": "192.0.2.35",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "local_preference": "6",
# "metric": "4",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "4",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "before": [
# {
# "entries": [
# {
# "action": "permit",
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# },
# {
# "action": "permit",
# "on_match": {
# "goto": 4
# },
# "sequence": 2
# }
# ],
# "route_map": "test2"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 1,
# "peer": "192.0.2.32",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "community": {
# "value": "internet"
# },
# "ip_next_hop": "192.0.2.33",
# "local_preference": "4",
# "metric": "5",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "5",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "changed": true,
# "commands": [
# "delete policy route-map test3 rule 1 set ip-next-hop 192.0.2.33",
# "set policy route-map test3 rule 1 set local-preference 6",
# "set policy route-map test3 rule 1 set metric 4",
# "set policy route-map test3 rule 1 set tag 4",
# "delete policy route-map test3 rule 1 set community internet",
# "set policy route-map test3 rule 1 match metric 3",
# "set policy route-map test3 rule 1 match peer 192.0.2.35"
# ],
#
# Using deleted:
# -------------
# Before state:
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# set policy route-map test3 rule 1 set local-preference 6
# set policy route-map test3 rule 1 set metric 4
# set policy route-map test3 rule 1 set tag 4
# set policy route-map test3 rule 1 match metric 3
# set policy route-map test3 rule 1 match peer 192.0.2.35
# vyos@vyos:~$
#
# - name: Delete the provided configuration
# register: result
# vyos.vyos.vyos_route_maps:
# config:
# state: deleted
# After state:
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# vyos@vyos:~$
#
#
# Module Execution:
#
# "after": [],
# "before": [
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 3,
# "peer": "192.0.2.35",
# },
# "sequence": 1,
# "set": {
# "local_preference": "6",
# "metric": "4",
# "tag": "4",
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "changed": true,
# "commands": [
# "delete policy route-map test3"
# ],
#
# using gathered:
# --------------
#
# Before state:
# vyos@vyos:~$ show configuration commands | match "set policy route-maps"
# set policy route-map test1 rule 1 description test
# set policy route-map test1 rule 1 action permit
# set policy route-map test1 rule 1 continue 2
# set policy route-map test1 rule 1 on-match next
# set policy route-map test3 rule 1 action permit
# set policy route-map test3 rule 1 set local-preference 4
# set policy route-map test3 rule 1 set metric 5
# set policy route-map test3 rule 1 set metric-type type-1
# set policy route-map test3 rule 1 set origin egp
# set policy route-map test3 rule 1 set originator-id 192.0.2.34
# set policy route-map test3 rule 1 set tag 5
# set policy route-map test3 rule 1 set weight 4
# set policy route-map test3 rule 1 match metric 1
# set policy route-map test3 rule 1 match peer 192.0.2.32
# set policy route-map test3 rule 1 match rpki invalid
#
# - name: gather configs
# vyos.vyos.vyos_route_maps:
# state: gathered
# "gathered": [
# {
# "entries": [
# {
# "action": "permit",
# "continue_sequence": 2,
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# }
# ],
# "route_map": "test1"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 1,
# "peer": "192.0.2.32",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "local_preference": "4",
# "metric": "5",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "5",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ]
# Using parsed:
# ------------
# parsed.cfg
# set policy route-map test1 rule 1 description test
# set policy route-map test1 rule 1 action permit
# set policy route-map test1 rule 1 continue 2
# set policy route-map test1 rule 1 on-match next
# set policy route-map test3 rule 1 action permit
# set policy route-map test3 rule 1 set local-preference 4
# set policy route-map test3 rule 1 set metric 5
# set policy route-map test3 rule 1 set metric-type type-1
# set policy route-map test3 rule 1 set origin egp
# set policy route-map test3 rule 1 set originator-id 192.0.2.34
# set policy route-map test3 rule 1 set tag 5
# set policy route-map test3 rule 1 set weight 4
# set policy route-map test3 rule 1 match metric 1
# set policy route-map test3 rule 1 match peer 192.0.2.32
# set policy route-map test3 rule 1 match rpki invalid
#
# - name: parse configs
# vyos.vyos.vyos_route_maps:
# running_config: "{{ lookup('file', './parsed.cfg') }}"
# state: parsed
# tags:
# - parsed
#
# Module execution:
# "parsed": [
# {
# "entries": [
# {
# "action": "permit",
# "continue_sequence": 2,
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# }
# ],
# "route_map": "test1"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 1,
# "peer": "192.0.2.32",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "local_preference": "4",
# "metric": "5",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "5",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ]
#
#
# Using rendered:
# --------------
# - name: Structure provided configuration into device specific commands
# register: result
# vyos.vyos.vyos_route_maps: &id001
# config:
# - route_map: test1
# entries:
# - sequence: 1
# description: "test"
# action: permit
# continue_sequence: 2
# on_match:
# next: True
# - route_map: test3
# entries:
# - sequence: 1
# action: permit
# match:
# rpki: invalid
# metric: 1
# peer: 192.0.2.32
# set:
# local_preference: 4
# metric: 5
# metric_type: "type-1"
# origin: egp
# originator_id: 192.0.2.34
# tag: 5
# weight: 4
# state: rendered
# Module Execution:
# "rendered": [
# "set policy route-map test1 rule 1 description test",
# "set policy route-map test1 rule 1 action permit",
# "set policy route-map test1 rule 1 continue 2",
# "set policy route-map test1 rule 1 on-match next",
# "set policy route-map test3 rule 1 action permit",
# "set policy route-map test3 rule 1 set local-preference 4",
# "set policy route-map test3 rule 1 set metric 5",
# "set policy route-map test3 rule 1 set metric-type type-1",
# "set policy route-map test3 rule 1 set origin egp",
# "set policy route-map test3 rule 1 set originator-id 192.0.2.34",
# "set policy route-map test3 rule 1 set tag 5",
# "set policy route-map test3 rule 1 set weight 4",
# "set policy route-map test3 rule 1 match metric 1",
# "set policy route-map test3 rule 1 match peer 192.0.2.32",
# "set policy route-map test3 rule 1 match rpki invalid"
# ]
#
#
# Using overridden:
# --------------
# Before state:
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# set policy route-map test2 rule 1 action 'permit'
# set policy route-map test2 rule 1 description 'test'
# set policy route-map test2 rule 1 on-match next
# set policy route-map test2 rule 2 action 'permit'
# set policy route-map test2 rule 2 on-match goto '4'
# set policy route-map test3 rule 1 action 'permit'
# set policy route-map test3 rule 1 match metric '1'
# set policy route-map test3 rule 1 match peer '192.0.2.32'
# set policy route-map test3 rule 1 match rpki 'invalid'
# set policy route-map test3 rule 1 set community 'internet'
# set policy route-map test3 rule 1 set ip-next-hop '192.0.2.33'
# set policy route-map test3 rule 1 set local-preference '4'
# set policy route-map test3 rule 1 set metric '5'
# set policy route-map test3 rule 1 set metric-type 'type-1'
# set policy route-map test3 rule 1 set origin 'egp'
# set policy route-map test3 rule 1 set originator-id '192.0.2.34'
# set policy route-map test3 rule 1 set tag '5'
# set policy route-map test3 rule 1 set weight '4'
#
# - name: Override the existing configuration with the provided running configuration
# register: result
# vyos.vyos.vyos_route_maps: &id001
# config:
# - route_map: test3
# entries:
# - sequence: 1
# action: permit
# match:
# rpki: invalid
# metric: 3
# peer: 192.0.2.35
# set:
# local_preference: 6
# metric: 4
# metric_type: "type-1"
# origin: egp
# originator_id: 192.0.2.34
# tag: 4
# weight: 4
# state: overridden
# After state:
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# set policy route-map test3 rule 1 set metric-type 'type-1'
# set policy route-map test3 rule 1 set origin 'egp'
# set policy route-map test3 rule 1 set originator-id '192.0.2.34'
# set policy route-map test3 rule 1 set weight '4'
# set policy route-map test3 rule 1 set local-preference 6
# set policy route-map test3 rule 1 set metric 4
# set policy route-map test3 rule 1 set tag 4
# set policy route-map test3 rule 1 match metric 3
# set policy route-map test3 rule 1 match peer 192.0.2.35
# set policy route-map test3 rule 1 match rpki 'invalid'
# Module Execution:
# "after": [
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 3,
# "peer": "192.0.2.35",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "local_preference": "6",
# "metric": "4",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "4",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "before": [
# {
# "entries": [
# {
# "action": "permit",
# "description": "test",
# "on_match": {
# "next": true
# },
# "sequence": 1
# },
# {
# "action": "permit",
# "on_match": {
# "goto": 4
# },
# "sequence": 2
# }
# ],
# "route_map": "test2"
# },
# {
# "entries": [
# {
# "action": "permit",
# "match": {
# "metric": 1,
# "peer": "192.0.2.32",
# "rpki": "invalid"
# },
# "sequence": 1,
# "set": {
# "community": {
# "value": "internet"
# },
# "ip_next_hop": "192.0.2.33",
# "local_preference": "4",
# "metric": "5",
# "metric_type": "type-1",
# "origin": "egp",
# "originator_id": "192.0.2.34",
# "tag": "5",
# "weight": "4"
# }
# }
# ],
# "route_map": "test3"
# }
# ],
# "changed": true,
# "commands": [
# "delete policy route-map test2",
# "delete policy route-map test3 rule 1 set ip-next-hop 192.0.2.33",
# "set policy route-map test3 rule 1 set local-preference 6",
# "set policy route-map test3 rule 1 set metric 4",
# "set policy route-map test3 rule 1 set tag 4",
# "delete policy route-map test3 rule 1 set community internet",
# "set policy route-map test3 rule 1 match metric 3",
# "set policy route-map test3 rule 1 match peer 192.0.2.35"
# ],
#