From 1d563009815dbbf6eeeb368ef14edc6f5ce4a2a2 Mon Sep 17 00:00:00 2001 From: omnom62 Date: Thu, 4 Jun 2026 06:34:07 +1000 Subject: Sanity fixes --- docs/vyos.rest.vyos_logging_global_module.rst | 30 ++++++++++++++- docs/vyos.rest.vyos_snmp_server_module.rst | 53 ++++++++++++++++++++------ plugins/httpapi/vyos.py | 13 ++++--- plugins/module_utils/vyos_rest.py | 4 +- plugins/modules/vyos_lldp_global.py | 1 + plugins/modules/vyos_logging_global.py | 38 +++++++++++++++--- plugins/modules/vyos_ntp_global.py | 16 +++++++- plugins/modules/vyos_route_maps.py | 2 +- plugins/modules/vyos_snmp_server.py | 55 +++++++++++++++++++++------ 9 files changed, 172 insertions(+), 40 deletions(-) diff --git a/docs/vyos.rest.vyos_logging_global_module.rst b/docs/vyos.rest.vyos_logging_global_module.rst index 718e646..da5572e 100644 --- a/docs/vyos.rest.vyos_logging_global_module.rst +++ b/docs/vyos.rest.vyos_logging_global_module.rst @@ -81,6 +81,7 @@ Parameters +
List of syslog facilities to log to the console.
@@ -98,6 +99,7 @@ Parameters +
Syslog facility name (e.g. local7, all, kern).
@@ -115,6 +117,7 @@ Parameters +
Minimum severity level to log (e.g. err, debug, all).
@@ -150,6 +153,7 @@ Parameters +
Log file archive/rotation settings.
@@ -167,6 +171,7 @@ Parameters +
Number of archived log files to keep.
@@ -184,6 +189,7 @@ Parameters +
Maximum size of log file in kilobytes before rotation.
@@ -202,6 +208,7 @@ Parameters +
List of syslog facilities to log to this file.
@@ -219,6 +226,7 @@ Parameters +
Syslog facility name.
@@ -236,6 +244,7 @@ Parameters +
Minimum severity level to log.
@@ -253,6 +262,7 @@ Parameters +
Path to the log file on the device.
@@ -286,6 +296,7 @@ Parameters +
Global log archive/rotation settings.
@@ -303,6 +314,7 @@ Parameters +
Number of archived log files to keep.
@@ -320,6 +332,7 @@ Parameters +
Maximum size of log file in kilobytes before rotation.
@@ -338,6 +351,7 @@ Parameters +
List of syslog facilities for global logging.
@@ -355,6 +369,7 @@ Parameters +
Syslog facility name.
@@ -372,6 +387,7 @@ Parameters +
Minimum severity level to log.
@@ -389,6 +405,7 @@ Parameters +
Interval in seconds between marker log entries.
@@ -409,6 +426,7 @@ Parameters +
Use the fully qualified domain name in syslog messages.
@@ -444,6 +462,7 @@ Parameters +
List of syslog facilities to forward to this host.
@@ -461,6 +480,7 @@ Parameters +
Syslog facility name.
@@ -478,7 +498,7 @@ Parameters -
Per-facility protocol override.
+
Per-facility protocol override (udp or tcp).
@@ -496,6 +516,7 @@ Parameters +
Minimum severity level to forward.
@@ -513,6 +534,7 @@ Parameters +
IP address or hostname of the remote syslog server.
@@ -529,6 +551,7 @@ Parameters +
UDP/TCP port on the remote syslog server (default 514).
@@ -545,6 +568,7 @@ Parameters +
Transport protocol (udp or tcp).
@@ -580,6 +604,7 @@ Parameters +
List of syslog facilities to send to this user.
@@ -597,6 +622,7 @@ Parameters +
Syslog facility name.
@@ -614,6 +640,7 @@ Parameters +
Minimum severity level to send.
@@ -631,6 +658,7 @@ Parameters +
Local username whose terminal receives log messages.
diff --git a/docs/vyos.rest.vyos_snmp_server_module.rst b/docs/vyos.rest.vyos_snmp_server_module.rst index dfa5259..29a64c6 100644 --- a/docs/vyos.rest.vyos_snmp_server_module.rst +++ b/docs/vyos.rest.vyos_snmp_server_module.rst @@ -85,7 +85,7 @@ Parameters -
Authorization type.
+
Authorization type (ro=read-only, rw=read-write).
@@ -207,7 +207,7 @@ Parameters -
IP address.
+
IP address to listen on.
@@ -308,6 +308,7 @@ Parameters +
SNMPv3 group configuration.
@@ -326,6 +327,7 @@ Parameters +
Group name.
@@ -347,6 +349,7 @@ Parameters +
Access mode (ro=read-only, rw=read-write).
@@ -368,6 +371,7 @@ Parameters +
Minimum security level required for group members.
@@ -385,6 +389,7 @@ Parameters +
View name the group has access to.
@@ -403,6 +408,7 @@ Parameters +
SNMPv3 trap target configuration.
@@ -420,6 +426,7 @@ Parameters +
IP address of the SNMPv3 trap target.
@@ -437,6 +444,7 @@ Parameters +
Authentication parameters for trap target.
@@ -455,6 +463,7 @@ Parameters +
Encrypted authentication key.
@@ -473,6 +482,7 @@ Parameters +
Plaintext authentication key.
@@ -491,6 +501,7 @@ Parameters +
Authentication algorithm.
@@ -509,6 +520,7 @@ Parameters +
UDP port on the trap target host.
@@ -526,6 +538,7 @@ Parameters +
Privacy parameters for trap target.
@@ -544,6 +557,7 @@ Parameters +
Encrypted privacy key.
@@ -562,6 +576,7 @@ Parameters +
Plaintext privacy key.
@@ -580,6 +595,7 @@ Parameters +
Privacy algorithm.
@@ -602,6 +618,7 @@ Parameters +
Transport protocol for traps.
@@ -623,6 +640,7 @@ Parameters +
Trap type.
@@ -641,6 +659,7 @@ Parameters +
SNMPv3 user configuration.
@@ -658,6 +677,7 @@ Parameters +
Authentication parameters for this user.
@@ -676,7 +696,7 @@ Parameters -
Encrypted key (stored as encrypted-password on device).
+
Encrypted authentication key (stored as encrypted-password on device).
@@ -695,7 +715,7 @@ Parameters -
Plaintext key (device encrypts it; recommended for 1.5+).
+
Plaintext authentication key (device encrypts it).
@@ -712,12 +732,9 @@ Parameters - +
Authentication algorithm.
@@ -736,6 +753,7 @@ Parameters +
Group this user belongs to.
@@ -757,6 +775,7 @@ Parameters +
Access mode for this user.
@@ -774,6 +793,7 @@ Parameters +
Privacy (encryption) parameters for this user.
@@ -792,6 +812,7 @@ Parameters +
Encrypted privacy key.
@@ -810,6 +831,7 @@ Parameters +
Plaintext privacy key (device encrypts it).
@@ -826,12 +848,9 @@ Parameters - +
Privacy algorithm.
@@ -850,6 +869,7 @@ Parameters +
TSM fingerprint of the certificate mapped to this user.
@@ -868,6 +888,7 @@ Parameters +
Username.
@@ -886,6 +907,7 @@ Parameters +
SNMPv3 view configuration.
@@ -903,6 +925,7 @@ Parameters +
OID subtree excluded from this view.
@@ -920,6 +943,7 @@ Parameters +
OID mask for the view.
@@ -937,6 +961,7 @@ Parameters +
OID subtree included in this view.
@@ -955,6 +980,7 @@ Parameters +
View name.
@@ -1005,6 +1031,7 @@ Parameters +
IP address of the trap target host.
@@ -1021,6 +1048,7 @@ Parameters +
Community name to use for traps.
@@ -1037,6 +1065,7 @@ Parameters +
UDP port on the trap target host.
diff --git a/plugins/httpapi/vyos.py b/plugins/httpapi/vyos.py index 6dd6042..07a60fe 100644 --- a/plugins/httpapi/vyos.py +++ b/plugins/httpapi/vyos.py @@ -1,6 +1,5 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- -# GNU General Public License v3.0+ +# 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 @@ -90,13 +89,14 @@ class HttpApi(HttpApiBase): ) return key - def send_request(self, endpoint, **payload): + def send_request(self, data, **payload): # pylint: disable=arguments-renamed """POST to a VyOS REST endpoint. Args: - endpoint (str): API path, e.g. '/configure' or '/retrieve'. - Named 'endpoint' not 'path' to avoid collision - with the VyOS payload field also called 'path'. + data (str): API path, e.g. '/configure' or '/retrieve'. + Named 'data' to match the HttpApiBase signature. + Internally referred to as endpoint to avoid collision + with the VyOS payload field also called 'data'. **payload: VyOS API fields: op, path, value, url, file, etc. Returns: @@ -105,6 +105,7 @@ class HttpApi(HttpApiBase): Raises: ConnectionError: on HTTP error or VyOS success=false response. """ + endpoint = data try: api_key = self._get_api_key() diff --git a/plugins/module_utils/vyos_rest.py b/plugins/module_utils/vyos_rest.py index aaf2b23..f4aa0dc 100644 --- a/plugins/module_utils/vyos_rest.py +++ b/plugins/module_utils/vyos_rest.py @@ -80,7 +80,7 @@ class VyOSRestClient: def _post_httpapi(self, endpoint, payload): try: - result = self._conn.send_request(endpoint=endpoint, **payload) + result = self._conn.send_request(endpoint, **payload) return result except ConnectionError as exc: raise VyOSRestError(str(exc)) @@ -192,7 +192,7 @@ class VyOSRestClient: if self._mode == "httpapi": try: return self._conn.send_request( - endpoint="/configure", + "/configure", _raw_list=commands, ) except ConnectionError as exc: diff --git a/plugins/modules/vyos_lldp_global.py b/plugins/modules/vyos_lldp_global.py index cc24be9..9ebbac0 100644 --- a/plugins/modules/vyos_lldp_global.py +++ b/plugins/modules/vyos_lldp_global.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# GNU General Public License v3.0+ from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py index be240ff..09fdd6b 100644 --- a/plugins/modules/vyos_logging_global.py +++ b/plugins/modules/vyos_logging_global.py @@ -1,15 +1,12 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# 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 -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.vyos.rest.plugins.module_utils.vyos import VyOSModule - - DOCUMENTATION = r""" --- module: vyos_logging_global @@ -33,12 +30,15 @@ options: type: dict suboptions: facilities: + description: List of syslog facilities to log to the console. type: list elements: dict suboptions: facility: + description: Syslog facility name (e.g. local7, all, kern). type: str severity: + description: Minimum severity level to log (e.g. err, debug, all). type: str files: description: Logging to local files. @@ -46,44 +46,59 @@ options: elements: dict suboptions: path: + description: Path to the log file on the device. type: str archive: + description: Log file archive/rotation settings. type: dict suboptions: file_num: + description: Number of archived log files to keep. type: int size: + description: Maximum size of log file in kilobytes before rotation. type: int facilities: + description: List of syslog facilities to log to this file. type: list elements: dict suboptions: facility: + description: Syslog facility name. type: str severity: + description: Minimum severity level to log. type: str global_params: description: Global syslog parameters (maps to C(system syslog global)). type: dict suboptions: archive: + description: Global log archive/rotation settings. type: dict suboptions: file_num: + description: Number of archived log files to keep. type: int size: + description: Maximum size of log file in kilobytes before rotation. type: int facilities: + description: List of syslog facilities for global logging. type: list elements: dict suboptions: facility: + description: Syslog facility name. type: str severity: + description: Minimum severity level to log. type: str marker_interval: + description: Interval in seconds between marker log entries. type: int preserve_fqdn: + description: Use the fully qualified domain name in syslog messages. type: bool hosts: description: Logging to remote syslog hosts. @@ -91,21 +106,27 @@ options: elements: dict suboptions: hostname: + description: IP address or hostname of the remote syslog server. type: str port: + description: UDP/TCP port on the remote syslog server (default 514). type: int protocol: + description: Transport protocol (udp or tcp). type: str facilities: + description: List of syslog facilities to forward to this host. type: list elements: dict suboptions: facility: + description: Syslog facility name. type: str severity: + description: Minimum severity level to forward. type: str protocol: - description: Per-facility protocol override. + description: Per-facility protocol override (udp or tcp). type: str users: description: Logging to local user terminals. @@ -113,14 +134,18 @@ options: elements: dict suboptions: username: + description: Local username whose terminal receives log messages. type: str facilities: + description: List of syslog facilities to send to this user. type: list elements: dict suboptions: facility: + description: Syslog facility name. type: str severity: + description: Minimum severity level to send. type: str running_config: @@ -213,6 +238,9 @@ saved: type: dict """ +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.rest.plugins.module_utils.vyos import VyOSModule + # ------------------------------------------------------------ # Normalization diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py index 88073e1..dd5fe4e 100644 --- a/plugins/modules/vyos_ntp_global.py +++ b/plugins/modules/vyos_ntp_global.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# 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 @@ -338,7 +339,20 @@ def main(): elements="dict", options=dict( server=dict(type="str", required=True), - options=dict(type="list", elements="str"), + options=dict( + type="list", + elements="str", + choices=[ + "dynamic", + "noselect", + "pool", + "preempt", + "prefer", + "nts", + "ptp", + "interleave", + ], + ), ), ), ), diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py index c72c66a..55b1706 100644 --- a/plugins/modules/vyos_route_maps.py +++ b/plugins/modules/vyos_route_maps.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- - +# GNU General Public License v3.0+ from __future__ import absolute_import, division, print_function diff --git a/plugins/modules/vyos_snmp_server.py b/plugins/modules/vyos_snmp_server.py index 9bdf451..3b40344 100644 --- a/plugins/modules/vyos_snmp_server.py +++ b/plugins/modules/vyos_snmp_server.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# GNU General Public License v3.0+ +# 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 @@ -41,7 +41,7 @@ options: type: list elements: str authorization_type: - description: Authorization type. + description: Authorization type (ro=read-only, rw=read-write). type: str choices: ['ro', 'rw'] contact: @@ -65,7 +65,7 @@ options: elements: dict suboptions: address: - description: IP address. + description: IP address to listen on. type: str required: true port: @@ -76,10 +76,13 @@ options: type: dict suboptions: address: + description: IP address of the trap target host. type: str community: + description: Community name to use for traps. type: str port: + description: UDP port on the trap target host. type: int snmp_v3: description: SNMPv3 configuration. @@ -89,104 +92,132 @@ options: description: EngineID as a hex string. type: str groups: + description: SNMPv3 group configuration. type: list elements: dict suboptions: group: + description: Group name. type: str required: true mode: + description: Access mode (ro=read-only, rw=read-write). type: str choices: ['ro', 'rw'] seclevel: + description: Minimum security level required for group members. type: str choices: ['auth', 'priv'] view: + description: View name the group has access to. type: str users: + description: SNMPv3 user configuration. type: list elements: dict suboptions: user: + description: Username. type: str required: true authentication: + description: Authentication parameters for this user. type: dict suboptions: type: + description: Authentication algorithm. type: str - choices: ['md5', 'sha'] encrypted_key: - description: Encrypted key (stored as encrypted-password on device). + description: Encrypted authentication key (stored as encrypted-password on device). type: str plaintext_key: - description: Plaintext key (device encrypts it; recommended for 1.5+). + description: Plaintext authentication key (device encrypts it). type: str - no_log: true privacy: + description: Privacy (encryption) parameters for this user. type: dict suboptions: type: + description: Privacy algorithm. type: str - choices: ['des', 'aes'] encrypted_key: + description: Encrypted privacy key. type: str plaintext_key: + description: Plaintext privacy key (device encrypts it). type: str - no_log: true group: + description: Group this user belongs to. type: str mode: + description: Access mode for this user. type: str choices: ['ro', 'rw'] tsm_key: + description: TSM fingerprint of the certificate mapped to this user. type: str trap_targets: + description: SNMPv3 trap target configuration. type: list elements: dict suboptions: address: + description: IP address of the SNMPv3 trap target. type: str port: + description: UDP port on the trap target host. type: int protocol: + description: Transport protocol for traps. type: str choices: ['tcp', 'udp'] type: + description: Trap type. type: str choices: ['inform', 'trap'] authentication: + description: Authentication parameters for trap target. type: dict suboptions: type: + description: Authentication algorithm. type: str encrypted_key: + description: Encrypted authentication key. type: str plaintext_key: + description: Plaintext authentication key. type: str - no_log: true privacy: + description: Privacy parameters for trap target. type: dict suboptions: type: + description: Privacy algorithm. type: str encrypted_key: + description: Encrypted privacy key. type: str plaintext_key: + description: Plaintext privacy key. type: str - no_log: true views: + description: SNMPv3 view configuration. type: list elements: dict suboptions: view: + description: View name. type: str required: true oid: + description: OID subtree included in this view. type: str exclude: + description: OID subtree excluded from this view. type: str mask: + description: OID mask for the view. type: str state: description: @@ -781,7 +812,7 @@ ARGUMENT_SPEC = dict( privacy=dict(type="dict", options=_auth_privacy_spec()), group=dict(type="str"), mode=dict(type="str", choices=["ro", "rw"]), - tsm_key=dict(type="str"), + tsm_key=dict(type="str", no_log=True), ), ), trap_targets=dict( -- cgit v1.2.3