diff --git a/docs/vyos.vyos.vyos_config_module.rst b/docs/vyos.vyos.vyos_config_module.rst index 1efbd38f..e2be25b9 100644 --- a/docs/vyos.vyos.vyos_config_module.rst +++ b/docs/vyos.vyos.vyos_config_module.rst @@ -1,396 +1,437 @@ .. _vyos.vyos.vyos_config_module: ********************* vyos.vyos.vyos_config ********************* **Manage VyOS configuration on remote device** Version added: 1.0.0 .. contents:: :local: :depth: 1 Synopsis -------- - This module provides configuration file management of VyOS devices. It provides arguments for managing both the configuration file and state of the active configuration. All configuration statements are based on `set` and `delete` commands in the device configuration. Parameters ---------- .. raw:: html + + + + + + + + + +
Parameter Choices/Defaults Comments
backup
boolean
    Choices:
  • no ←
  • yes
The backup argument will backup the current devices active configuration to the Ansible control host prior to making any changes. If the backup_options value is not given, the backup file will be located in the backup folder in the playbook root directory or role root directory, if playbook is part of an ansible role. If the directory does not exist, it is created.
backup_options
dictionary
This is a dict object containing configurable options related to backup file path. The value of this option is read only when backup is set to yes, if backup is set to no this option will be silently ignored.
dir_path
path
This option provides the path ending with directory name in which the backup configuration file will be stored. If the directory does not exist it will be first created and the filename is either the value of filename or default filename as described in filename options description. If the path value is not given in that case a backup directory will be created in the current working directory and backup configuration will be copied in filename within backup directory.
filename
string
The filename to be used to store the backup configuration. If the filename is not given it will be generated based on the hostname, current time and date in format defined by <hostname>_config.<current-date>@<current-time>
comment
string
Default:
"configured by vyos_config"
Allows a commit description to be specified to be included when the configuration is committed. If the configuration is not changed or committed, this argument is ignored.
config
string
The config argument specifies the base configuration to use to compare against the desired configuration. If this value is not specified, the module will automatically retrieve the current active configuration from the remote device. The configuration lines in the option value should be similar to how it will appear if present in the running-configuration of the device including indentation to ensure idempotency and correct diff.
+
+ confirm + +
+ string +
+
+
    Choices: +
  • automatic
  • +
  • manual
  • +
  • none ←
  • +
+
+
The confirm argument will tell vyos to revert to the previous configuration if not explicitly confirmed after applying the new config. When set to automatic this module will automatically confirm the configuration, if the current session remains working with the new config. When set to manual, this module does not issue the confirmation itself.
+
+
+ confirm_timeout + +
+ integer +
+
+ Default:
10
+
+
Minutes to wait for confirmation before reverting the configuration. Does not apply when confirm is set to none .
+
lines
list / elements=string
The ordered set of commands that should be configured in the section. The commands must be the exact same commands as found in the device running-config as found in the device running-config to ensure idempotency and correct diff. Be sure to note the configuration command syntax as some commands are automatically modified by the device config parser.
match
string
    Choices:
  • line ←
  • none
The match argument controls the method used to match against the current active configuration. By default, the desired config is matched against the active config and the deltas are loaded. If the match argument is set to none the active configuration is ignored and the configuration is always loaded.
save
boolean
    Choices:
  • no ←
  • yes
The save argument controls whether or not changes made to the active configuration are saved to disk. This is independent of committing the config. When set to True, the active configuration is saved.
src
path
The src argument specifies the path to the source config file to load. The source config file can either be in bracket format or set format. The source file can include Jinja2 template variables. The configuration lines in the source file should be similar to how it will appear if present in the running-configuration of the device including indentation to ensure idempotency and correct diff.

Notes ----- .. note:: - Tested against VyOS 1.3.8, 1.4.2, the upcoming 1.5, and the rolling release of spring 2025. - This module works with connection ``ansible.netcommon.network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. - To ensure idempotency and correct diff the configuration lines in the relevant module options should be similar to how they appear if present in the running configuration on device including the indentation. - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` Examples -------- .. code-block:: yaml - name: configure the remote device vyos.vyos.vyos_config: lines: - set system host-name {{ inventory_hostname }} - set service lldp - delete service dhcp-server - name: backup and load from file vyos.vyos.vyos_config: src: vyos.cfg backup: true - name: render a Jinja2 template onto the VyOS router vyos.vyos.vyos_config: src: vyos_template.j2 + - name: revert after ten minutes, if connection is lost + vyos.vyos.vyos_config: + src: vyos_template.j2 + confirm: automatic + - name: for idempotency, use full-form commands vyos.vyos.vyos_config: lines: # - set int eth eth2 description 'OUTSIDE' - set interface ethernet eth2 description 'OUTSIDE' - name: configurable backup path vyos.vyos.vyos_config: backup: true backup_options: filename: backup.cfg dir_path: /home/user Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
backup_path
string
when backup is yes
The full path to the backup file

Sample:
/playbooks/ansible/backup/vyos_config.2016-07-16@22:28:34
commands
list
always
The list of configuration commands sent to the device

Sample:
['...', '...']
date
string
when backup is yes
The date extracted from the backup file name

Sample:
2016-07-16
filename
string
when backup is yes and filename is not specified in backup options
The name of the backup file

Sample:
vyos_config.2016-07-16@22:28:34
filtered
list
always
The list of configuration commands removed to avoid a load failure

Sample:
['...', '...']
shortname
string
when backup is yes and filename is not specified in backup options
The full path to the backup file excluding the timestamp

Sample:
/playbooks/ansible/backup/vyos_config
time
string
when backup is yes
The time extracted from the backup file name

Sample:
22:28:34


Status ------ Authors ~~~~~~~ - Nathaniel Case (@Qalthos) diff --git a/docs/vyos.vyos.vyos_vrrp_module.rst b/docs/vyos.vyos.vyos_vrrp_module.rst index 882c7dae..fc71be3a 100644 --- a/docs/vyos.vyos.vyos_vrrp_module.rst +++ b/docs/vyos.vyos.vyos_vrrp_module.rst @@ -1,2522 +1,2522 @@ .. _vyos.vyos.vyos_vrrp_module: ******************* vyos.vyos.vyos_vrrp ******************* **Manage VRRP and load balancer configuration on VyOS** Version added: 1.0.0 .. contents:: :local: :depth: 1 Synopsis -------- - This module configures VRRP groups, global VRRP parameters, VRRP sync groups, and LVS-style virtual servers on VyOS 1.4+. - Supports creation, modification, deletion, replacement, rendering, and parsing of VRRP-related configuration. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
config
dictionary
Full VRRP and virtual server configuration.
disable
boolean
    Choices: -
  • no
  • +
  • no ←
  • yes
Disable all VRRP and L4-LB configuration under this module.
virtual_servers
list / elements=dictionary
List of load balancer virtual server (LVS) definitions.
address
string
Virtual IP address for the server.
algorithm
string
Load balancing algorithm used for dispatching connections.
delay_loop
integer
Delay loop interval in seconds.
forward_method
string
    Choices:
  • direct
  • nat
Forwarding method used by LVS.
fwmark
integer
Firewall mark for LVS traffic classification.
name
string / required
Unique identifier for the virtual server.
persistence_timeout
integer
Client persistence timeout in seconds.
port
integer
TCP/UDP port provided by the virtual service.
protocol
string
    Choices:
  • tcp
  • udp
Transport protocol for the virtual server.
real_server
list / elements=dictionary
Backend real servers behind the virtual service.
address
string / required
Real server IP address.
connection_timeout
integer
Backend server connection timeout.
health_check_script
string
Path to health check script used for backend validation.
port
integer
Backend server port.
vrrp
dictionary
VRRP configuration including groups, global parameters, SNMP settings, and sync-groups.
global_parameters
dictionary
Global VRRP tuning parameters.
garp
dictionary
Gratuitous ARP related configuration.
interval
integer
GARP interval in seconds.
master_delay
integer
Delay before sending GARP as master.
master_refresh
integer
Refresh interval for master GARP announcements.
master_refresh_repeat
integer
Number of times to repeat refresh announcements.
master_repeat
integer
Number of GARP repeats when transitioning to master.
startup_delay
integer
Delay before VRRP starts after boot.
version
string
VRRP protocol version.
groups
list / elements=dictionary
VRRP instance configuration groups.
address
string
Virtual router IP address.
advertise_interval
integer
VRRP advertisement interval.
authentication
dictionary
VRRP group authentication options.
password
string
Authentication password.
type
string
Authentication type.
description
string
Text description for the VRRP group.
disable
boolean
    Choices:
  • no ←
  • yes
Disable this VRRP group.
excluded_address
list / elements=string
IP address excluded from source checks.
garp
dictionary
GARP-specific settings for this group.
interval
integer
GARP interval.
master_delay
integer
GARP master delay.
master_refresh
integer
GARP master refresh interval.
master_refresh_repeat
integer
Repeated refresh sends.
master_repeat
integer
GARP repeat count.
health_check
dictionary
VRRP group health check options.
failure_count
integer
Allowed number of failed checks.
interval
integer
Health check interval.
ping
string
Host to ping for checks.
script
string
Script to execute for health checking.
hello_source_address
string
Source address for VRRP hello packets.
interface
string
Interface used by the VRRP group.
name
string / required
VRRP group name.
no_preempt
boolean
    Choices:
  • no ←
  • yes
Disable preemption.
peer_address
string
Peer VRRP router address.
preempt_delay
integer
Delay before taking master role.
priority
integer
VRRP priority (higher = preferred master).
rfc3768_compatibility
boolean
    Choices:
  • no ←
  • yes
Enable or disable RFC3768 compatibility mode.
track
dictionary
Track interface and VRRP behaviour.
exclude_vrrp_interface
boolean
    Choices:
  • no
  • yes
Exclude VRRP interface from tracking.
interface
list / elements=string
Interface to track.
transition_script
dictionary
Scripts executed during VRRP state transitions.
backup
string
Path to backup script.
fault
string
Path to fault script.
master
string
Path to master script.
stop
string
Path to stop script.
vrid
integer
VRRP Virtual Router ID.
snmp
string
    Choices:
  • enabled
  • disabled
Enable SNMP support for VRRP.
sync_groups
list / elements=dictionary
VRRP sync-groups for coordinated failover.
health_check
dictionary
Health check options for sync group.
failure_count
integer
Allowed number of failures.
interval
integer
Health check interval.
ping
string
Host to ping.
script
string
Script to run for health checking.
member
list / elements=string
List of VRRP groups participating in this sync group.
name
string / required
Sync-group name.
transition_script
dictionary
Transition scripts for sync group events.
backup
string
Backup state script.
fault
string
Fault state script.
master
string
Master state script.
stop
string
Stop state script.
running_config
string
Used only when state=parsed. Must contain the output of show configuration commands | grep high-availability.
state
string
    Choices:
  • deleted
  • merged ←
  • purged
  • replaced
  • gathered
  • rendered
  • parsed
  • overridden
Desired end state of the VRRP configuration.

Examples -------- .. code-block:: yaml # Using merged # Before state # vyos@vyos:~$ show configuration commands | match "set high-availability" # vyos@vyos:~$ - name: Merge provided configuration with device configuration vyos.vyos.vyos_vrrp: config: disable: true virtual_servers: - name: s1 address: 10.10.10.5 algorithm: round-robin real_server: - address: 10.10.50.2 port: 8443 - name: s2 address: 10.10.10.2 persistence_timeout: 30 port: 81 protocol: tcp - name: s3 address: 10.10.10.3 port: 88 protocol: udp vrrp: snmp: enabled global_parameters: startup_delay: 30 garp: master_repeat: 6 groups: - name: "g1" peer_address: 192.168.1.3 priority: 100 disable: false no_preempt: false vrid: 20 sync_groups: - name: "sg1" health_check: failure_count: 5 state: merged # After State # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": false # }, # "changed": true, # "commands": [ # "set high-availability disable", # "set high-availability virtual-server s1 address 10.10.10.5", # "set high-availability virtual-server s1 algorithm round-robin", # "set high-availability virtual-server s1 real-server 10.10.50.2 port 8443", # "set high-availability virtual-server s2 address 10.10.10.2", # "set high-availability virtual-server s2 persistence-timeout 30", # "set high-availability virtual-server s2 port 81", # "set high-availability virtual-server s2 protocol tcp", # "set high-availability virtual-server s3 address 10.10.10.3", # "set high-availability virtual-server s3 port 88", # "set high-availability virtual-server s3 protocol udp", # "set high-availability vrrp global-parameters garp master-repeat 6", # "set high-availability vrrp global-parameters startup-delay 30", # "set high-availability vrrp group g1 peer-address 192.168.1.3", # "set high-availability vrrp group g1 priority 100", # "set high-availability vrrp group g1 vrid 20", # "set high-availability vrrp snmp", # "set high-availability vrrp sync-group sg1 health-check failure-count 5" # ], # Using replaced: # -------------- # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Replace vyos.vyos.vyos_vrrp: config: disable: false virtual_servers: - name: s1 address: 10.10.10.3 algorithm: round-robin port: 8443 real_server: - address: 10.10.50.3 port: 8443 - name: s2 address: 10.10.10.2 persistence_timeout: 300 port: 81 protocol: tcp real_server: - address: 10.10.50.30 port: 8443 - name: s3 address: 10.10.10.3 port: 88 protocol: udp real_server: - address: 10.10.50.6 port: 8443 vrrp: snmp: enabled global_parameters: startup_delay: 30 garp: master_repeat: 6 groups: - name: "g1" peer_address: 192.168.1.13 priority: 100 disable: false no_preempt: true interface: eth1 address: 192.168.51.13 vrid: 20 sync_groups: - name: "sg1" health_check: failure_count: 3 state: replaced # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability virtual-server s1 address '10.10.10.3' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 port '8443' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s1 real-server 10.10.50.3 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '300' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s2 real-server 10.10.50.3 port '8443' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability virtual-server s3 real-server 10.10.50.6 port '8443' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 address 192.168.51.13 # set high-availability vrrp group g1 interface 'eth1' # set high-availability vrrp group g1 no-preempt # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 peer-address '192.168.1.13' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '3' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": false, # "virtual_servers": [ # { # "address": "10.10.10.3", # "algorithm": "round-robin", # "name": "s1", # "port": 8443, # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # }, # { # "address": "10.10.50.3", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 300, # "port": 81, # "protocol": "tcp", # "real_server": [ # { # "address": "10.10.50.3", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp", # "real_server": [ # { # "address": "10.10.50.6", # "port": 8443 # } # ] # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "address": "192.168.51.13", # "disable": false, # "interface": "eth1", # "name": "g1", # "no_preempt": true, # "peer_address": "192.168.1.13", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 3 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability disable", # "set high-availability virtual-server s1 address 10.10.10.3", # "set high-availability virtual-server s1 port 8443", # "set high-availability virtual-server s1 real-server 10.10.50.3 port 8443", # "set high-availability virtual-server s2 persistence-timeout 300", # "set high-availability virtual-server s2 real-server 10.10.50.3 port 8443", # "set high-availability virtual-server s3 real-server 10.10.50.6 port 8443", # "set high-availability vrrp group g1 address 192.168.51.13", # "set high-availability vrrp group g1 interface eth1", # "set high-availability vrrp group g1 no-preempt", # "set high-availability vrrp group g1 peer-address 192.168.1.13", # "set high-availability vrrp sync-group sg1 health-check failure-count 3" # ], # Using deleted: # ------------- # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Delete configuration vyos.vyos.vyos_vrrp: config: disable: false vrrp: snmp: disabled global_parameters: startup_delay: 32 version: 3 virtual_servers: - name: 's1' address: '10.10.10.1' algorithm: 'round-robin' delay_loop: 60 forward_method: 'direct' persistence_timeout: 30 port: 443 protocol: 'tcp' real_server: - address: '10.10.10.1' connection_timeout: 61 port: 443 state: deleted # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # } # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability virtual-server s1", # "delete high-availability vrrp global-parameters startup-delay" # ], # Using purged: # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Purge configuration vyos.vyos.vyos_vrrp: config: state: purged # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # vyos@vyos:~$ # # Module Execution: # # "after": { # "disable": false # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # } # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability" # ], # using gathered: # -------------- # Before state: # vyos@vyos:~$ # show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: gather configs vyos.vyos.vyos_vrrp: state: gathered # Module Execution: # "changed": false, # "gathered": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # # Using parsed: # ------------ # parsed.cfg # set high-availability vrrp group g1 interface eth2 # set high-availability vrrp group g1 address 1.1.1.1 # set high-availability vrrp group g1 disable # set high-availability vrrp group g1 no-preempt # set high-availability vrrp group g1 advertise-interval 10 # set high-availability vrrp group g1 peer-address 2.2.2.2 # set high-availability vrrp group g1 rfc3768-compatibility # set high-availability vrrp group g1 vrid 20 - name: parse configs vyos.vyos.vyos_vrrp: running_config: "{{ lookup('file', './parsed.cfg') }}" state: parsed # Module execution: # "parsed": { # "disable": false, # "vrrp": { # "groups": [ # { # "address": "1.1.1.1", # "advertise_interval": 10, # "disable": true, # "interface": "eth2", # "name": "g1", # "no_preempt": true, # "peer_address": "2.2.2.2", # "rfc3768_compatibility": true, # "vrid": 20 # } # ] # } # } # # Using rendered: # -------------- - name: Render vyos.vyos.vyos_vrrp: config: disable: true vrrp: snmp: enabled global_parameters: startup_delay: 32 version: 3 garp: interval: 30 master_delay: 11 master_refresh: 100 master_refresh_repeat: 200 master_repeat: 5 state: rendered # Module Execution: # "rendered": [ # "set high-availability disable", # "set high-availability vrrp global-parameters garp interval 30", # "set high-availability vrrp global-parameters garp master-delay 11", # "set high-availability vrrp global-parameters garp master-refresh 100", # "set high-availability vrrp global-parameters garp master-refresh-repeat 200", # "set high-availability vrrp global-parameters garp master-repeat 5", # "set high-availability vrrp global-parameters startup-delay 32", # "set high-availability vrrp global-parameters version 3", # "set high-availability vrrp snmp" # ] Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
after
dictionary
when changed
The resulting configuration after module execution.

Sample:
This output will always be in the same format as the module argspec.
before
dictionary
when state is merged, replaced, overridden, deleted or purged
The configuration prior to the module execution.

Sample:
This output will always be in the same format as the module argspec.
commands
list
when state is merged, replaced, overridden, deleted or purged
The set of commands pushed to the remote device.

Sample:
["set high-availability vrrp group g1 address '1.1.1.1'", "set high-availability vrrp group g1 advertise-interval '10'", "set high-availability vrrp group g1 description 'Group 1'"]
gathered
list
when state is gathered
Facts about the network resource gathered from the remote device as structured data.

Sample:
This output will always be in the same format as the module argspec.
parsed
list
when state is parsed
The device native config provided in running_config option parsed into structured data as per module argspec.

Sample:
This output will always be in the same format as the module argspec.
rendered
list
when state is rendered
The provided configuration in the task rendered in device-native format (offline).

Sample:
["set high-availability vrrp global-parameters garp master-delay '10'", "set high-availability vrrp global-parameters garp master-refresh '100'", "set high-availability vrrp global-parameters garp master-refresh-repeat '200'"]


Status ------ Authors ~~~~~~~ - Evgeny Molotkov (@omnom62) diff --git a/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py b/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py index c8865d09..22e9f255 100644 --- a/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py +++ b/plugins/module_utils/network/vyos/argspec/vrrp/vrrp.py @@ -1,196 +1,196 @@ # -*- 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": {"type": "bool"}, + "disable": {"type": "bool", "default": False}, "virtual_servers": { "type": "list", "elements": "dict", "options": { "name": {"type": "str", "required": True}, "address": {"type": "str"}, "algorithm": {"type": "str"}, "delay_loop": {"type": "int"}, "forward_method": {"type": "str", "choices": ["direct", "nat"]}, "fwmark": {"type": "int"}, "persistence_timeout": {"type": "int"}, "port": {"type": "int"}, "protocol": {"type": "str", "choices": ["tcp", "udp"]}, "real_server": { "type": "list", "elements": "dict", "options": { "address": {"type": "str", "required": True}, "port": {"type": "int"}, "connection_timeout": {"type": "int"}, "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"}, }, }, "startup_delay": {"type": "int"}, "version": {"type": "str"}, }, }, "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"}, }, }, "description": {"type": "str"}, "disable": {"type": "bool", "default": False}, "excluded_address": {"type": "list", "elements": "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", "default": False}, "peer_address": {"type": "str"}, "preempt_delay": {"type": "int"}, "priority": {"type": "int"}, "rfc3768_compatibility": {"type": "bool", "default": False}, "track": { "type": "dict", "options": { "exclude_vrrp_interface": {"type": "bool"}, "interface": {"type": "list", "elements": "str"}, }, }, "transition_script": { "type": "dict", "options": { "backup": {"type": "str"}, "fault": {"type": "str"}, "master": {"type": "str"}, "stop": {"type": "str"}, }, }, "vrid": {"type": "int", "required": False}, }, }, "snmp": { "type": "str", "choices": ["disabled", "enabled"], }, "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", "overridden", ], "default": "merged", }, "running_config": {"type": "str"}, } # pylint: disable=C0301 diff --git a/plugins/modules/vyos_vrrp.py b/plugins/modules/vyos_vrrp.py index 111247e9..56fe0929 100644 --- a/plugins/modules/vyos_vrrp.py +++ b/plugins/modules/vyos_vrrp.py @@ -1,1325 +1,1326 @@ #!/usr/bin/python # -*- 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) """ The module file for vyos_vrrp """ from __future__ import absolute_import, division, print_function __metaclass__ = type DOCUMENTATION = r""" --- module: vyos_vrrp author: Evgeny Molotkov (@omnom62) short_description: Manage VRRP and load balancer configuration on VyOS version_added: "1.0.0" description: - This module configures VRRP groups, global VRRP parameters, VRRP sync groups, and LVS-style virtual servers on VyOS 1.4+. - Supports creation, modification, deletion, replacement, rendering, and parsing of VRRP-related configuration. options: config: description: - Full VRRP and virtual server configuration. type: dict suboptions: disable: description: - Disable all VRRP and L4-LB configuration under this module. type: bool + default: false virtual_servers: description: - List of load balancer virtual server (LVS) definitions. type: list elements: dict suboptions: name: description: - Unique identifier for the virtual server. type: str required: true address: description: - Virtual IP address for the server. type: str algorithm: description: - Load balancing algorithm used for dispatching connections. type: str delay_loop: description: - Delay loop interval in seconds. type: int forward_method: description: - Forwarding method used by LVS. type: str choices: [direct, nat] fwmark: description: - Firewall mark for LVS traffic classification. type: int persistence_timeout: description: - Client persistence timeout in seconds. type: int port: description: - TCP/UDP port provided by the virtual service. type: int protocol: description: - Transport protocol for the virtual server. type: str choices: [tcp, udp] real_server: description: - Backend real servers behind the virtual service. type: list elements: dict suboptions: address: description: - Real server IP address. type: str required: true port: description: - Backend server port. type: int connection_timeout: description: - Backend server connection timeout. type: int health_check_script: description: - Path to health check script used for backend validation. type: str vrrp: description: - VRRP configuration including groups, global parameters, SNMP settings, and sync-groups. type: dict suboptions: global_parameters: description: - Global VRRP tuning parameters. type: dict suboptions: garp: description: - Gratuitous ARP related configuration. type: dict suboptions: interval: description: - GARP interval in seconds. type: int master_delay: description: - Delay before sending GARP as master. type: int master_refresh: description: - Refresh interval for master GARP announcements. type: int master_refresh_repeat: description: - Number of times to repeat refresh announcements. type: int master_repeat: description: - Number of GARP repeats when transitioning to master. type: int startup_delay: description: - Delay before VRRP starts after boot. type: int version: description: - VRRP protocol version. type: str groups: description: - VRRP instance configuration groups. type: list elements: dict suboptions: name: description: - VRRP group name. type: str required: true address: description: - Virtual router IP address. type: str advertise_interval: description: - VRRP advertisement interval. type: int authentication: description: - VRRP group authentication options. type: dict suboptions: password: description: - Authentication password. type: str type: description: - Authentication type. type: str description: description: - Text description for the VRRP group. type: str disable: description: - Disable this VRRP group. type: bool default: false excluded_address: description: - IP address excluded from source checks. type: list elements: str garp: description: - GARP-specific settings for this group. type: dict suboptions: interval: description: GARP interval. type: int master_delay: description: GARP master delay. type: int master_refresh: description: GARP master refresh interval. type: int master_refresh_repeat: description: Repeated refresh sends. type: int master_repeat: description: GARP repeat count. type: int health_check: description: - VRRP group health check options. type: dict suboptions: failure_count: description: Allowed number of failed checks. type: int interval: description: Health check interval. type: int ping: description: Host to ping for checks. type: str script: description: Script to execute for health checking. type: str hello_source_address: description: - Source address for VRRP hello packets. type: str interface: description: - Interface used by the VRRP group. type: str no_preempt: description: - Disable preemption. type: bool default: false peer_address: description: - Peer VRRP router address. type: str preempt_delay: description: - Delay before taking master role. type: int priority: description: - VRRP priority (higher = preferred master). type: int rfc3768_compatibility: description: - Enable or disable RFC3768 compatibility mode. type: bool default: false track: description: - Track interface and VRRP behaviour. type: dict suboptions: exclude_vrrp_interface: description: - Exclude VRRP interface from tracking. type: bool interface: description: - Interface to track. type: list elements: str transition_script: description: - Scripts executed during VRRP state transitions. type: dict suboptions: backup: description: Path to backup script. type: str fault: description: Path to fault script. type: str master: description: Path to master script. type: str stop: description: Path to stop script. type: str vrid: description: - VRRP Virtual Router ID. type: int snmp: description: - Enable SNMP support for VRRP. type: str choices: ['enabled', 'disabled'] sync_groups: description: - VRRP sync-groups for coordinated failover. type: list elements: dict suboptions: name: description: - Sync-group name. type: str required: true health_check: description: - Health check options for sync group. type: dict suboptions: failure_count: description: Allowed number of failures. type: int interval: description: Health check interval. type: int ping: description: Host to ping. type: str script: description: Script to run for health checking. type: str member: description: - List of VRRP groups participating in this sync group. type: list elements: str transition_script: description: - Transition scripts for sync group events. type: dict suboptions: backup: description: Backup state script. type: str fault: description: Fault state script. type: str master: description: Master state script. type: str stop: description: Stop state script. type: str state: description: - Desired end state of the VRRP configuration. type: str choices: - deleted - merged - purged - replaced - gathered - rendered - parsed - overridden default: merged running_config: description: - Used only when C(state=parsed). Must contain the output of C(show configuration commands | grep high-availability). type: str """ EXAMPLES = """ # Using merged # Before state # vyos@vyos:~$ show configuration commands | match "set high-availability" # vyos@vyos:~$ - name: Merge provided configuration with device configuration vyos.vyos.vyos_vrrp: config: disable: true virtual_servers: - name: s1 address: 10.10.10.5 algorithm: round-robin real_server: - address: 10.10.50.2 port: 8443 - name: s2 address: 10.10.10.2 persistence_timeout: 30 port: 81 protocol: tcp - name: s3 address: 10.10.10.3 port: 88 protocol: udp vrrp: snmp: enabled global_parameters: startup_delay: 30 garp: master_repeat: 6 groups: - name: "g1" peer_address: 192.168.1.3 priority: 100 disable: false no_preempt: false vrid: 20 sync_groups: - name: "sg1" health_check: failure_count: 5 state: merged # After State # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": false # }, # "changed": true, # "commands": [ # "set high-availability disable", # "set high-availability virtual-server s1 address 10.10.10.5", # "set high-availability virtual-server s1 algorithm round-robin", # "set high-availability virtual-server s1 real-server 10.10.50.2 port 8443", # "set high-availability virtual-server s2 address 10.10.10.2", # "set high-availability virtual-server s2 persistence-timeout 30", # "set high-availability virtual-server s2 port 81", # "set high-availability virtual-server s2 protocol tcp", # "set high-availability virtual-server s3 address 10.10.10.3", # "set high-availability virtual-server s3 port 88", # "set high-availability virtual-server s3 protocol udp", # "set high-availability vrrp global-parameters garp master-repeat 6", # "set high-availability vrrp global-parameters startup-delay 30", # "set high-availability vrrp group g1 peer-address 192.168.1.3", # "set high-availability vrrp group g1 priority 100", # "set high-availability vrrp group g1 vrid 20", # "set high-availability vrrp snmp", # "set high-availability vrrp sync-group sg1 health-check failure-count 5" # ], # Using replaced: # -------------- # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Replace vyos.vyos.vyos_vrrp: config: disable: false virtual_servers: - name: s1 address: 10.10.10.3 algorithm: round-robin port: 8443 real_server: - address: 10.10.50.3 port: 8443 - name: s2 address: 10.10.10.2 persistence_timeout: 300 port: 81 protocol: tcp real_server: - address: 10.10.50.30 port: 8443 - name: s3 address: 10.10.10.3 port: 88 protocol: udp real_server: - address: 10.10.50.6 port: 8443 vrrp: snmp: enabled global_parameters: startup_delay: 30 garp: master_repeat: 6 groups: - name: "g1" peer_address: 192.168.1.13 priority: 100 disable: false no_preempt: true interface: eth1 address: 192.168.51.13 vrid: 20 sync_groups: - name: "sg1" health_check: failure_count: 3 state: replaced # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability virtual-server s1 address '10.10.10.3' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 port '8443' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s1 real-server 10.10.50.3 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '300' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s2 real-server 10.10.50.3 port '8443' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability virtual-server s3 real-server 10.10.50.6 port '8443' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 address 192.168.51.13 # set high-availability vrrp group g1 interface 'eth1' # set high-availability vrrp group g1 no-preempt # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 peer-address '192.168.1.13' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '3' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": false, # "virtual_servers": [ # { # "address": "10.10.10.3", # "algorithm": "round-robin", # "name": "s1", # "port": 8443, # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # }, # { # "address": "10.10.50.3", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 300, # "port": 81, # "protocol": "tcp", # "real_server": [ # { # "address": "10.10.50.3", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp", # "real_server": [ # { # "address": "10.10.50.6", # "port": 8443 # } # ] # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "address": "192.168.51.13", # "disable": false, # "interface": "eth1", # "name": "g1", # "no_preempt": true, # "peer_address": "192.168.1.13", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 3 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability disable", # "set high-availability virtual-server s1 address 10.10.10.3", # "set high-availability virtual-server s1 port 8443", # "set high-availability virtual-server s1 real-server 10.10.50.3 port 8443", # "set high-availability virtual-server s2 persistence-timeout 300", # "set high-availability virtual-server s2 real-server 10.10.50.3 port 8443", # "set high-availability virtual-server s3 real-server 10.10.50.6 port 8443", # "set high-availability vrrp group g1 address 192.168.51.13", # "set high-availability vrrp group g1 interface eth1", # "set high-availability vrrp group g1 no-preempt", # "set high-availability vrrp group g1 peer-address 192.168.1.13", # "set high-availability vrrp sync-group sg1 health-check failure-count 3" # ], # Using deleted: # ------------- # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Delete configuration vyos.vyos.vyos_vrrp: config: disable: false vrrp: snmp: disabled global_parameters: startup_delay: 32 version: 3 virtual_servers: - name: 's1' address: '10.10.10.1' algorithm: 'round-robin' delay_loop: 60 forward_method: 'direct' persistence_timeout: 30 port: 443 protocol: 'tcp' real_server: - address: '10.10.10.1' connection_timeout: 61 port: 443 state: deleted # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ # # # Module Execution: # # "after": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # } # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability virtual-server s1", # "delete high-availability vrrp global-parameters startup-delay" # ], # Using purged: # Before state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: Purge configuration vyos.vyos.vyos_vrrp: config: state: purged # After state: # vyos@vyos:~$ show configuration commands | match "set high-availability" # vyos@vyos:~$ # # Module Execution: # # "after": { # "disable": false # }, # "before": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # } # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # "changed": true, # "commands": [ # "delete high-availability" # ], # using gathered: # -------------- # Before state: # vyos@vyos:~$ # show configuration commands | match "set high-availability" # set high-availability disable # set high-availability virtual-server s1 address '10.10.10.5' # set high-availability virtual-server s1 algorithm 'round-robin' # set high-availability virtual-server s1 real-server 10.10.50.2 port '8443' # set high-availability virtual-server s2 address '10.10.10.2' # set high-availability virtual-server s2 persistence-timeout '30' # set high-availability virtual-server s2 port '81' # set high-availability virtual-server s2 protocol 'tcp' # set high-availability virtual-server s3 address '10.10.10.3' # set high-availability virtual-server s3 port '88' # set high-availability virtual-server s3 protocol 'udp' # set high-availability vrrp global-parameters garp master-repeat '6' # set high-availability vrrp global-parameters startup-delay '30' # set high-availability vrrp group g1 peer-address '192.168.1.3' # set high-availability vrrp group g1 priority '100' # set high-availability vrrp group g1 vrid '20' # set high-availability vrrp snmp # set high-availability vrrp sync-group sg1 health-check failure-count '5' # vyos@vyos:~$ - name: gather configs vyos.vyos.vyos_vrrp: state: gathered # Module Execution: # "changed": false, # "gathered": { # "disable": true, # "virtual_servers": [ # { # "address": "10.10.10.5", # "algorithm": "round-robin", # "name": "s1", # "real_server": [ # { # "address": "10.10.50.2", # "port": 8443 # } # ] # }, # { # "address": "10.10.10.2", # "name": "s2", # "persistence_timeout": 30, # "port": 81, # "protocol": "tcp" # }, # { # "address": "10.10.10.3", # "name": "s3", # "port": 88, # "protocol": "udp" # } # ], # "vrrp": { # "global_parameters": { # "garp": { # "master_repeat": 6 # }, # "startup_delay": 30 # }, # "groups": [ # { # "disable": false, # "name": "g1", # "no_preempt": false, # "peer_address": "192.168.1.3", # "priority": 100, # "rfc3768_compatibility": false, # "vrid": 20 # } # ], # "snmp": "enabled", # "sync_groups": [ # { # "health_check": { # "failure_count": 5 # }, # "name": "sg1" # } # ] # } # }, # # Using parsed: # ------------ # parsed.cfg # set high-availability vrrp group g1 interface eth2 # set high-availability vrrp group g1 address 1.1.1.1 # set high-availability vrrp group g1 disable # set high-availability vrrp group g1 no-preempt # set high-availability vrrp group g1 advertise-interval 10 # set high-availability vrrp group g1 peer-address 2.2.2.2 # set high-availability vrrp group g1 rfc3768-compatibility # set high-availability vrrp group g1 vrid 20 - name: parse configs vyos.vyos.vyos_vrrp: running_config: "{{ lookup('file', './parsed.cfg') }}" state: parsed # Module execution: # "parsed": { # "disable": false, # "vrrp": { # "groups": [ # { # "address": "1.1.1.1", # "advertise_interval": 10, # "disable": true, # "interface": "eth2", # "name": "g1", # "no_preempt": true, # "peer_address": "2.2.2.2", # "rfc3768_compatibility": true, # "vrid": 20 # } # ] # } # } # # Using rendered: # -------------- - name: Render vyos.vyos.vyos_vrrp: config: disable: true vrrp: snmp: enabled global_parameters: startup_delay: 32 version: 3 garp: interval: 30 master_delay: 11 master_refresh: 100 master_refresh_repeat: 200 master_repeat: 5 state: rendered # Module Execution: # "rendered": [ # "set high-availability disable", # "set high-availability vrrp global-parameters garp interval 30", # "set high-availability vrrp global-parameters garp master-delay 11", # "set high-availability vrrp global-parameters garp master-refresh 100", # "set high-availability vrrp global-parameters garp master-refresh-repeat 200", # "set high-availability vrrp global-parameters garp master-repeat 5", # "set high-availability vrrp global-parameters startup-delay 32", # "set high-availability vrrp global-parameters version 3", # "set high-availability vrrp snmp" # ] """ RETURN = """ before: description: The configuration prior to the module execution. returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: dict sample: > This output will always be in the same format as the module argspec. after: description: The resulting configuration after module execution. returned: when changed type: dict sample: > This output will always be in the same format as the module argspec. commands: description: The set of commands pushed to the remote device. returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - set high-availability vrrp group g1 address '1.1.1.1' - set high-availability vrrp group g1 advertise-interval '10' - set high-availability vrrp group g1 description 'Group 1' rendered: description: The provided configuration in the task rendered in device-native format (offline). returned: when I(state) is C(rendered) type: list sample: - set high-availability vrrp global-parameters garp master-delay '10' - set high-availability vrrp global-parameters garp master-refresh '100' - set high-availability vrrp global-parameters garp master-refresh-repeat '200' gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) type: list sample: > This output will always be in the same format as the module argspec. parsed: description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. returned: when I(state) is C(parsed) type: list sample: > This output will always be in the same format as the module argspec. """ from ansible.module_utils.basic import AnsibleModule 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.config.vrrp.vrrp import ( Vrrp, ) def main(): """ Main entry point for module execution :returns: the result form module invocation """ module = AnsibleModule( argument_spec=VrrpArgs.argument_spec, mutually_exclusive=[["config", "running_config"]], required_if=[ ["state", "merged", ["config"]], ["state", "replaced", ["config"]], ["state", "overridden", ["config"]], ["state", "rendered", ["config"]], ["state", "parsed", ["running_config"]], ], supports_check_mode=True, ) result = Vrrp(module).execute_module() module.exit_json(**result) if __name__ == "__main__": main()