Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F117521262
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
43 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py b/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py
index 86afeedc..707c8498 100644
--- a/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py
+++ b/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py
@@ -1,63 +1,192 @@
# -*- coding: utf-8 -*-
# Copyright 2024 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
#############################################
# WARNING #
#############################################
#
# This file is auto generated by the
# cli_rm_builder.
#
# Manually editing this file is not advised.
#
# To update the argspec make the desired changes
# in the module docstring and re-run
# cli_rm_builder.
#
#############################################
"""
The arg spec for the vyos_vrrp module
"""
class VrrpArgs(object): # pylint: disable=R0903
"""The arg spec for the vyos_vrrp module"""
argument_spec = {
"config": {
"type": "dict",
+ "required": False,
"options": {
- "disable": {"aliases": ["disabled"], "type": "bool", "default": False},
- "virtual_server": {
+ "disable": {"type": "bool"},
+ "virtual_servers": {
"type": "list",
"elements": "dict",
"options": {
- "name": {"required": True, "type": "str"},
- "address": {"type": "str"},
+ "name": {"type": "str", "required": True},
+ "address": {"type": "str", "required": True},
+ "algorithm": {
+ "type": "str",
+ "choices": ["round_robin", "weighted_round_robin", "least_connection"],
+ },
+ "delay_loop": {"type": "str"},
+ "forward_method": {"type": "str", "choices": ["direct", "nat"]},
+ "fwmark": {"type": "str"},
+ "persistence_timeout": {"type": "str"},
+ "port": {"type": "str"},
+ "protocol": {"type": "str", "choices": ["tcp", "udp"]},
+ "real_server": {
+ "type": "list",
+ "elements": "dict",
+ "options": {
+ "address": {"type": "str", "required": True},
+ "port": {"type": "str"},
+ "health_check_script": {"type": "str"},
+ },
+ },
+ },
+ },
+ "vrrp": {
+ "type": "dict",
+ "options": {
+ "global_parameters": {
+ "type": "dict",
+ "options": {
+ "garp": {
+ "type": "dict",
+ "options": {
+ "interval": {"type": "int"},
+ "master_delay": {"type": "int"},
+ "master_refresh": {"type": "int"},
+ "master_refresh_repeat": {"type": "int"},
+ "master_repeat": {"type": "int"},
+ },
+ },
+ },
+ },
+ "groups": {
+ "type": "list",
+ "elements": "dict",
+ "options": {
+ "name": {"type": "str", "required": True},
+ "address": {"type": "str"},
+ "advertise_interval": {"type": "int"},
+ "authentication": {
+ "type": "dict",
+ "options": {
+ "password": {"type": "str", "no_log": True},
+ "type": {"type": "str", "choices": ["plaintext_password"]},
+ },
+ },
+ "description": {"type": "str"},
+ "disable": {"type": "bool"},
+ "excluded_address": {"type": "str"},
+ "garp": {
+ "type": "dict",
+ "options": {
+ "interval": {"type": "int"},
+ "master_delay": {"type": "int"},
+ "master_refresh": {"type": "int"},
+ "master_refresh_repeat": {"type": "int"},
+ "master_repeat": {"type": "int"},
+ },
+ },
+ "health_check": {
+ "type": "dict",
+ "options": {
+ "failure_count": {"type": "int"},
+ "interval": {"type": "int"},
+ "ping": {"type": "str"},
+ "script": {"type": "str"},
+ },
+ },
+ "hello_source_address": {"type": "str"},
+ "interface": {"type": "str"},
+ "no_preempt": {"type": "bool"},
+ "peer_address": {"type": "str"},
+ "preempt_delay": {"type": "int"},
+ "priority": {"type": "int"},
+ "rfc3768_compatibility": {"type": "bool"},
+ "track": {
+ "type": "dict",
+ "options": {
+ "exclude_vrrp_interface": {"type": "bool"},
+ "interface": {"type": "str"},
+ },
+ },
+ "transition_script": {
+ "type": "dict",
+ "options": {
+ "backup": {"type": "str"},
+ "fault": {"type": "str"},
+ "master": {"type": "str"},
+ "stop": {"type": "str"},
+ },
+ },
+ "vrid": {"type": "int", "required": True},
+ },
+ },
+ "snmp": {"type": "bool"},
+ "sync_groups": {
+ "type": "list",
+ "elements": "dict",
+ "options": {
+ "name": {"type": "str", "required": True},
+ "health_check": {
+ "type": "dict",
+ "options": {
+ "failure_count": {"type": "int"},
+ "interval": {"type": "int"},
+ "ping": {"type": "str"},
+ "script": {"type": "str"},
+ },
+ },
+ "member": {"type": "list", "elements": "str"},
+ "transition_script": {
+ "type": "dict",
+ "options": {
+ "backup": {"type": "str"},
+ "fault": {"type": "str"},
+ "master": {"type": "str"},
+ "stop": {"type": "str"},
+ },
+ },
+ },
+ },
},
},
},
},
"state": {
"type": "str",
"choices": [
"deleted",
"merged",
"purged",
"replaced",
"gathered",
"rendered",
"parsed",
],
"default": "merged",
},
"running_config": {"type": "str"},
} # pylint: disable=C0301
diff --git a/plugins/module_utils/network/vyos/facts/vrrp/vrrp.py b/plugins/module_utils/network/vyos/facts/vrrp/vrrp.py
index 83eca11a..efb4a979 100644
--- a/plugins/module_utils/network/vyos/facts/vrrp/vrrp.py
+++ b/plugins/module_utils/network/vyos/facts/vrrp/vrrp.py
@@ -1,125 +1,124 @@
# -*- coding: utf-8 -*-
# Copyright 2021 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
"""
The vyos vrrp fact class
It is in this file the configuration is collected from the device
for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
import re
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.vrrp.vrrp import (
VrrpArgs,
)
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.vrrp import (
VrrpTemplate,
)
class VrrpFacts(object):
"""The vyos vrrp facts class"""
def __init__(self, module, subspec="config", options="options"):
self._module = module
self.argument_spec = VrrpArgs.argument_spec
def get_device_data(self, connection):
return connection.get('show configuration commands | match "set high-availability"')
def get_config_set(self, data, connection):
"""To classify the configurations beased on vrrp"""
config_dict = {}
for config_line in data.splitlines():
vrrp_grp = re.search(r"set high-availability vrrp group (\S+).*", config_line)
vrrp_snmp = re.search(r"set high-availability vrrp snmp", config_line)
vrrp_gp = re.search(
r"set high-availability vrrp global-parameters (\S+).*",
config_line,
)
vrrp_sg = re.search(r"set high-availability vrrp sync-group (\S+).*", config_line)
vrrp_vsrv = re.search(r"set high-availability virtual-server (\S+).*", config_line)
vrrp_disable = re.search(r"set high-availability disable", config_line)
if vrrp_disable:
config_dict["disable"] = config_dict.get("disable", "") + config_line + "\n"
if vrrp_gp:
config_dict["global_parameters"] = (
config_dict.get(vrrp_gp.group(1), "") + config_line + "\n"
)
if vrrp_vsrv:
config_dict[vrrp_vsrv.group(1)] = (
config_dict.get(vrrp_vsrv.group(1), "") + config_line + "\n"
)
if vrrp_sg:
config_dict[vrrp_sg.group(1)] = (
config_dict.get(vrrp_sg.group(1), "") + config_line + "\n"
)
if vrrp_grp:
config_dict[vrrp_grp.group(1)] = (
config_dict.get(vrrp_grp.group(1), "") + config_line + "\n"
)
return list(config_dict.values())
def deep_merge(self, dest, src):
for key, value in src.items():
if key in dest and isinstance(dest[key], dict) and isinstance(value, dict):
self.deep_merge(dest[key], value)
else:
dest[key] = value
return dest
def populate_facts(self, connection, ansible_facts, data=None):
"""Populate the facts for vrrp network resource
:param connection: the device connection
:param ansible_facts: Facts dictionary
:param data: previously collected conf
:rtype: dictionary
:returns: facts
"""
facts = {}
objs = {}
config_lines = []
if not data:
data = self.get_device_data(connection)
vrrp_facts = {"virtual_servers": {}, "sync_groups": {}, "vrrp": {}}
- groups = []
resources = self.get_config_set(data, connection)
for resource in data.splitlines():
vrrp_parser = VrrpTemplate(
lines=resource.split("\n"),
module=self._module,
)
objs = vrrp_parser.parse()
if "disable" in objs:
vrrp_facts["disable"] = objs["disable"]
- if "vrrp" in objs:
- groups.append(objs)
- for section in ("virtual_servers", "sync_groups", "vrrp"):
+ # if "vrrp" in objs:
+ # groups.append(objs)
+ for section in ("virtual_servers", "vrrp"):
if section in objs:
for name, data in objs[section].items():
existing = vrrp_facts[section].get(name, {})
vrrp_facts[section][name] = self.deep_merge(existing, data)
self._module.fail_json(msg=str(vrrp_facts))
ansible_facts["ansible_network_resources"].pop("vrrp", None)
params = utils.remove_empties(
vrrp_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),
)
facts["vrrp"] = params.get("config", [])
ansible_facts["ansible_network_resources"].update(facts)
self._module.fail_json(msg="STOP")
return ansible_facts
diff --git a/plugins/module_utils/network/vyos/rm_templates/vrrp.py b/plugins/module_utils/network/vyos/rm_templates/vrrp.py
index a57505b7..d481daff 100644
--- a/plugins/module_utils/network/vyos/rm_templates/vrrp.py
+++ b/plugins/module_utils/network/vyos/rm_templates/vrrp.py
@@ -1,659 +1,665 @@
# -*- coding: utf-8 -*-
# Copyright 2021 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
"""
The Bgp_global parser templates file. This contains
a list of parser definitions and associated functions that
facilitates both facts gathering and native command generation for
the given network resource.
"""
import re
# from ansible.module_utils.six import iteritems
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import (
NetworkTemplate,
)
class VrrpTemplate(NetworkTemplate):
def __init__(self, lines=None, module=None):
prefix = {"set": "set", "remove": "delete"}
super(VrrpTemplate, self).__init__(
lines=lines,
tmplt=self,
prefix=prefix,
module=module,
)
def _tmplt_vsrvs(config_data):
config_data = config_data["virtual-server"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vsrvs_rsrv(config_data):
config_data = config_data["virtual-server"]["real_servers"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_sgroup_hc(config_data):
config_data = config_data["sync-group"]["health-check"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_sgroup_ts(config_data):
config_data = config_data["sync-group"]["transition-script"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_gp(config_data):
config_data = config_data["vrrp"]["global-parameters"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_gp_garp(config_data):
config_data = config_data["vrrp"]["global-parameters"]["garp"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group(config_data):
config_data = config_data["vrrp"]["group"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group_track(config_data):
config_data = config_data["vrrp"]["group"]["track"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group_hc(config_data):
config_data = config_data["vrrp"]["group"]["health-check"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group_ts(config_data):
config_data = config_data["vrrp"]["group"]["transcription-script"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group_garp(config_data):
config_data = config_data["vrrp"]["group"]["garp"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
def _tmplt_vrrp_group_auth(config_data):
config_data = config_data["vrrp"]["group"]["authentication"]
command = []
# cmd = "service snmp v3 group {group}".format(**config_data)
# if "mode" in config_data:
# mode_cmd = cmd + " mode {mode}".format(**config_data)
# command.append(mode_cmd)
# if "seclevel" in config_data:
# sec_cmd = cmd + " seclevel {seclevel}".format(**config_data)
# command.append(sec_cmd)
# if "view" in config_data:
# view_cmd = cmd + " view {view}".format(**config_data)
# command.append(view_cmd)
return command
# fmt: off
PARSERS = [
{
"name": "disable",
"getval": re.compile(
r"""
^set
\shigh-availability
\s(?P<disable>disable)
$""",
re.VERBOSE,
),
"setval": "high-availability disable",
"result": {
"disable": "{{ True if disable is defined }}",
},
},
{
"name": "virtual_servers",
"getval": re.compile(
r"""
^set\shigh-availability\svirtual-server
\s+(?P<alias>\S+)
(?:\s+address\s+(?P<address>\S+))?
(?:\s+algorithm\s+(?P<algorithm>\S+))?
(?:\s+delay-loop\s+(?P<delay_loop>\S+))?
(?:\s+forward-method\s+(?P<forward_method>\S+))?
(?:\s+fwmark\s+(?P<fwmark>\S+))?
(?:\s+persistence-timeout\s+(?P<persistence_timeout>\S+))?
(?:\s+port\s+(?P<port>\S+))?
(?:\s+protocol\s+(?P<protocol>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vsrvs,
"result": {
"virtual_servers": {
"{{ alias }}": {
"alias": "{{ alias }}",
"address": "{{ address if address is defined else None }}",
"algorithm": "{{ algorithm if algorithm is defined else None }}",
"delay_loop": "{{ delay_loop if delay_loop is defined else None }}",
"forward_method": "{{ forward_method if forward_method is defined else None }}",
"fwmark": "{{ fwmark if fwmark is defined else None }}",
"persistence_timeout": "{{ persistence_timeout if persistence_timeout is defined else None }}",
"port": "{{ port if port is defined else None }}",
"protocol": "{{ protocol if protocol is defined else None }}",
},
},
},
},
{
"name": "virtual_servers.real_servers",
"getval": re.compile(
r"""
^set\shigh-availability\svirtual-server
\s+(?P<alias>\S+)
\sreal-server
\s+(?P<name>\S+)
(?:\s+port\s+(?P<port>\S+))?
(?:\s+health-check\sscript\s+(?P<hcscript>\S+))?
(?:\s+connection-timeout\s+(?P<cont>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vsrvs_rsrv,
# "compval": "global_parameters.garp.master_refersh_repeat",
"result": {
"virtual_servers": {
"{{ alias }}": {
"alias": "{{ alias }}",
"real_servers": {
"{{ name }}": {
"name": "{{ name }}",
"port": "{{ port if port is defined else None }}",
"health_check_script": "{{ hcscript if hcscript is defined else None }}",
"connection_timeout": "{{ cont if cont is defined else None }}",
},
},
},
},
},
},
{
"name": "sync_group.member",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\ssync-group
\s+(?P<sgname>\S+)
\smember
\s+(?P<member>\S+)
$
""",
re.VERBOSE,
),
"setval": "set high-availability vrrp sync-group {{sgname}} member {{member}}",
"compval": "sync_groups.member",
"result": {
- "sync_groups": {
- "{{ sgname }}": {
- "name": "{{ sgname }}",
- "member": "{{ member }}",
+ "vrrp": {
+ "sync_groups": {
+ "{{ sgname }}": {
+ "name": "{{ sgname }}",
+ "member": "{{ member }}",
+ },
},
},
},
},
{
"name": "sync_group.health_check",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\ssync-group
\s+(?P<sgname>\S+)
\shealth-check
(?:\s+failure-count\s+(?P<failure_count>\S+))
?(?:\s+interval\s+(?P<int>\S+))
?(?:\s+ping\s+(?P<ping>\S+))
?(?:\s+script\s+(?P<script>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_sgroup_hc,
# "compval": "global_parameters.garp.master_refersh_repeat",
"result": {
- "sync_groups": {
- "{{ sgname }}": {
- "name": "{{ sgname }}",
- "health_check": {
- "failure_count": "{{ failure_count if failure_count is defined else None }}",
- "interval": "{{ int if int is defined else None }}",
- "ping": "{{ ping if ping is defined else None }}",
- "script": "{{ script if script is defined else None }}",
+ "vrrp": {
+ "sync_groups": {
+ "{{ sgname }}": {
+ "name": "{{ sgname }}",
+ "health_check": {
+ "failure_count": "{{ failure_count if failure_count is defined else None }}",
+ "interval": "{{ int if int is defined else None }}",
+ "ping": "{{ ping if ping is defined else None }}",
+ "script": "{{ script if script is defined else None }}",
+ },
},
},
},
},
},
{
"name": "sync_group.transition_script",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\ssync-group
\s+(?P<sgname>\S+)
\stransition-script
(?:\s+backup\s+(?P<backup>\S+))?
(?:\s+fault\s+(?P<fault>\S+))?
(?:\s+master\s+(?P<master>\S+))?
(?:\s+stop\s+(?P<stop>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_sgroup_ts,
# "compval": "global_parameters.garp.master_refersh_repeat",
"result": {
- "sync_groups": {
- "{{ sgname }}": {
- "name": "{{ sgname }}",
- "transition_script": {
- "backup": "{{ backup if backup is defined else None }}",
- "fault": "{{ fault if fault is defined else None }}",
- "master": "{{ master if master is defined else None }}",
- "stop": "{{ stop if stop is defined else None }}",
+ "vrrp": {
+ "sync_groups": {
+ "{{ sgname }}": {
+ "name": "{{ sgname }}",
+ "transition_script": {
+ "backup": "{{ backup if backup is defined else None }}",
+ "fault": "{{ fault if fault is defined else None }}",
+ "master": "{{ master if master is defined else None }}",
+ "stop": "{{ stop if stop is defined else None }}",
+ },
},
},
},
},
},
{
"name": "vrrp.global_parameters.garp",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sglobal-parameters
\s+garp
(?:\s+interval\s+(?P<interval>\S+))?
(?:\s+master-delay\s+(?P<master_delay>\S+))?
(?:\s+master-refresh\s+(?P<master_refresh>\S+))?
(?:\s+master-refresh-repeat\s+(?P<master_refresh_repeat>\S+))?
(?:\s+master-repeat\s+(?P<master_repeat>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_gp_garp,
"result": {
"vrrp": {
"global_parameters": {
"garp": {
"interval": "{{ interval if interval is defined else None }}",
"master-delay": "{{ master_delay if master_delay is defined else None }}",
"master-refresh": "{{ master_refresh if master_refresh is defined else None }}",
"master-refresh-repeat": "{{ master_refresh_repeat if master_refresh_repeat is defined else None }}",
"master-repeat": "{{ master_repeat if master_repeat is defined else None }}",
},
},
},
},
},
{
"name": "vrrp.global_parameters",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sglobal-parameters
(?:\s+startup-delay\s+(?P<startup_delay>\S+))?
(?:\s+version\s+(?P<version>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_gp,
"result": {
"vrrp": {
"global_parameters": {
"startup-delay": "{{ startup_delay if startup_delay is defined else None }}",
"version": "{{ version if version is defined else None }}",
},
},
},
},
{
"name": "vrrp.group",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<group_name>\S+)
(?:\s+address\s+(?P<address>\S+))?
(?:\s+description\s+(?P<description>'.+?'|\S+))?
(?:\s+hello-source-address\s+(?P<hello_source>\S+))?
(?:\s+interface\s+(?P<interface>\S+))?
(?:\s+(?P<no_preempt>no-preempt))?
(?:\s+peer-address\s+(?P<peer_address>\S+))?
(?:\s+priority\s+(?P<priority>\S+))?
(?:\s+vrid\s+(?P<vrid>\S+))?
(?:\s+rfc3768-compatibility\s+(?P<rfc3768_compatibility>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group,
"result": {
"vrrp": {
"groups": {
"{{ group_name }}": {
"name": "{{ group_name }}",
"address": "{{ address if address is defined else None }}",
"description": "{{ description.strip(\"'\") if description is defined else None }}",
"hello-source-address": "{{ hello_source if hello_source is defined else None }}",
"interface": "{{ interface if interface is defined else None }}",
"no-preempt": "{{ True if no_preempt is defined else False }}",
"peer-address": "{{ peer_address if peer_address is defined else None }}",
"priority": "{{ priority if priority is defined else None }}",
"vrid": "{{ vrid if vrid is defined else None }}",
"rfc3768-compatibility": "{{ rfc3768_compatibility if rfc3768_compatibility is defined else None }}",
},
},
},
},
},
{
"name": "vrrp.group.authentication",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<group_name>\S+)
\s+(?P<authentication>\S+)
(?:\s+password\s+(?P<password>\S+))?
(?:\s+type\s+(?P<type>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_auth,
"result": {
"vrrp": {
"groups": {
"{{ group_name }}": {
"name": "{{ group_name }}",
"authentication": {
"password": "{{ password if password is defined else None }}",
"type": "{{ type if type is defined else None }}",
},
},
},
},
},
},
{
"name": "vrrp.group.garp",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+garp
(?:\s+interval\s+(?P<interval>\S+))?
(?:\s+master-delay\s+(?P<master_delay>\S+))?
(?:\s+master-refresh\s+(?P<master_refresh>\S+))?
(?:\s+master-refresh-repeat\s+(?P<master_refresh_repeat>\S+))?
(?:\s+master-repeat\s+(?P<master_repeat>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_garp,
"result": {
"vrrp": {
- "group": {
+ "groups": {
"garp": {
"interval": "{{ interval if interval is defined else None }}",
"master-delay": "{{ master_delay if master_delay is defined else None }}",
"master-refresh": "{{ master_refresh if master_refresh is defined else None }}",
"master-refresh-repeat": "{{ master_refresh_repeat if master_refresh_repeat is defined else None }}",
"master-repeat": "{{ master_repeat if master_repeat is defined else None }}",
},
},
},
},
},
{
"name": "vrrp.group.transition_script",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<gname>\S+)
\stransition-script
(?:\s+backup\s+(?P<backup>\S+))?
(?:\s+fault\s+(?P<fault>\S+))?
(?:\s+master\s+(?P<master>\S+))?
(?:\s+stop\s+(?P<stop>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_ts,
# "compval": "global_parameters.garp.master_refersh_repeat",
"result": {
"vrrp": {
"groups": {
"{{ gname }}": {
"name": "{{ gname }}",
"transition_script": {
"backup": "{{ backup if backup is defined else None }}",
"fault": "{{ fault if fault is defined else None }}",
"master": "{{ master if master is defined else None }}",
"stop": "{{ stop if stop is defined else None }}",
},
},
},
},
},
},
{
"name": "vrrp.group.health_check",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<group_name>\S+)
\shealth-check
(?:\s+failure-count\s+(?P<failure_count>\S+))
?(?:\s+interval\s+(?P<int>\S+))
?(?:\s+ping\s+(?P<ping>\S+))
?(?:\s+script\s+(?P<script>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_hc,
# "compval": "global_parameters.garp.master_refersh_repeat",
"result": {
"vrrp": {
"groups": {
"{{ group_name }}": {
"name": "{{ group_name }}",
"health_check": {
"failure_count": "{{ failure_count if failure_count is defined else None }}",
"interval": "{{ int if int is defined else None }}",
"ping": "{{ ping if ping is defined else None }}",
"script": "{{ script if script is defined else None }}",
},
},
},
},
},
},
{
"name": "vrrp.group.track",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<group_name>\S+)
\strack
(?:\s+exculde-vrrp-interface\s+(?P<exclude_vrrp_inter>\S+))?
(?:\s+interface\s+(?P<interface>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_track,
"result": {
"vrrp": {
"groups": {
"{{ group_name }}": {
"name": "{{ group_name }}",
"track": {
"exclude-vrrp-interface": "{{ exclude-vrrp-inter if exclude-vrrp-inter is defined else None }}",
"interface": "{{ interface if interface is defined else None }}",
},
},
},
},
},
},
{
"name": "vrrp.group.excluded_address",
"getval": re.compile(
r"""
^set\shigh-availability\svrrp\sgroup
\s+(?P<group_name>\S+)
\sexcluded-address\s+(?P<address>\S+)
(?:\s+interface\s+(?P<interface>\S+))?
$
""",
re.VERBOSE,
),
"setval": _tmplt_vrrp_group_auth,
"result": {
"vrrp": {
"groups": {
"{{ group_name }}": {
"name": "{{ group_name }}",
"excluded_address": {
"{{ address }}": {
"name": "{{ address }}",
"interface": "{{ interface if interface is defined else None }}",
},
},
},
},
},
},
},
]
# fmt: on
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Sep 26, 2:32 PM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4285404
Default Alt Text
(43 KB)
Attached To
Mode
R52 VyOS Ansible Collection
Attached
Detach File
Event Timeline
Log In to Comment