diff options
| -rw-r--r-- | docs/vyos.rest.vyos_logging_global_module.rst | 30 | ||||
| -rw-r--r-- | docs/vyos.rest.vyos_snmp_server_module.rst | 53 | ||||
| -rw-r--r-- | plugins/httpapi/vyos.py | 13 | ||||
| -rw-r--r-- | plugins/module_utils/vyos_rest.py | 4 | ||||
| -rw-r--r-- | plugins/modules/vyos_lldp_global.py | 1 | ||||
| -rw-r--r-- | plugins/modules/vyos_logging_global.py | 38 | ||||
| -rw-r--r-- | plugins/modules/vyos_ntp_global.py | 16 | ||||
| -rw-r--r-- | plugins/modules/vyos_route_maps.py | 2 | ||||
| -rw-r--r-- | 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 <td> </td> <td> + <div>List of syslog facilities to log to the console.</div> </td> </tr> <tr> @@ -98,6 +99,7 @@ Parameters <td> </td> <td> + <div>Syslog facility name (e.g. local7, all, kern).</div> </td> </tr> <tr> @@ -115,6 +117,7 @@ Parameters <td> </td> <td> + <div>Minimum severity level to log (e.g. err, debug, all).</div> </td> </tr> @@ -150,6 +153,7 @@ Parameters <td> </td> <td> + <div>Log file archive/rotation settings.</div> </td> </tr> <tr> @@ -167,6 +171,7 @@ Parameters <td> </td> <td> + <div>Number of archived log files to keep.</div> </td> </tr> <tr> @@ -184,6 +189,7 @@ Parameters <td> </td> <td> + <div>Maximum size of log file in kilobytes before rotation.</div> </td> </tr> @@ -202,6 +208,7 @@ Parameters <td> </td> <td> + <div>List of syslog facilities to log to this file.</div> </td> </tr> <tr> @@ -219,6 +226,7 @@ Parameters <td> </td> <td> + <div>Syslog facility name.</div> </td> </tr> <tr> @@ -236,6 +244,7 @@ Parameters <td> </td> <td> + <div>Minimum severity level to log.</div> </td> </tr> @@ -253,6 +262,7 @@ Parameters <td> </td> <td> + <div>Path to the log file on the device.</div> </td> </tr> @@ -286,6 +296,7 @@ Parameters <td> </td> <td> + <div>Global log archive/rotation settings.</div> </td> </tr> <tr> @@ -303,6 +314,7 @@ Parameters <td> </td> <td> + <div>Number of archived log files to keep.</div> </td> </tr> <tr> @@ -320,6 +332,7 @@ Parameters <td> </td> <td> + <div>Maximum size of log file in kilobytes before rotation.</div> </td> </tr> @@ -338,6 +351,7 @@ Parameters <td> </td> <td> + <div>List of syslog facilities for global logging.</div> </td> </tr> <tr> @@ -355,6 +369,7 @@ Parameters <td> </td> <td> + <div>Syslog facility name.</div> </td> </tr> <tr> @@ -372,6 +387,7 @@ Parameters <td> </td> <td> + <div>Minimum severity level to log.</div> </td> </tr> @@ -389,6 +405,7 @@ Parameters <td> </td> <td> + <div>Interval in seconds between marker log entries.</div> </td> </tr> <tr> @@ -409,6 +426,7 @@ Parameters </ul> </td> <td> + <div>Use the fully qualified domain name in syslog messages.</div> </td> </tr> @@ -444,6 +462,7 @@ Parameters <td> </td> <td> + <div>List of syslog facilities to forward to this host.</div> </td> </tr> <tr> @@ -461,6 +480,7 @@ Parameters <td> </td> <td> + <div>Syslog facility name.</div> </td> </tr> <tr> @@ -478,7 +498,7 @@ Parameters <td> </td> <td> - <div>Per-facility protocol override.</div> + <div>Per-facility protocol override (udp or tcp).</div> </td> </tr> <tr> @@ -496,6 +516,7 @@ Parameters <td> </td> <td> + <div>Minimum severity level to forward.</div> </td> </tr> @@ -513,6 +534,7 @@ Parameters <td> </td> <td> + <div>IP address or hostname of the remote syslog server.</div> </td> </tr> <tr> @@ -529,6 +551,7 @@ Parameters <td> </td> <td> + <div>UDP/TCP port on the remote syslog server (default 514).</div> </td> </tr> <tr> @@ -545,6 +568,7 @@ Parameters <td> </td> <td> + <div>Transport protocol (udp or tcp).</div> </td> </tr> @@ -580,6 +604,7 @@ Parameters <td> </td> <td> + <div>List of syslog facilities to send to this user.</div> </td> </tr> <tr> @@ -597,6 +622,7 @@ Parameters <td> </td> <td> + <div>Syslog facility name.</div> </td> </tr> <tr> @@ -614,6 +640,7 @@ Parameters <td> </td> <td> + <div>Minimum severity level to send.</div> </td> </tr> @@ -631,6 +658,7 @@ Parameters <td> </td> <td> + <div>Local username whose terminal receives log messages.</div> </td> </tr> 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 </ul> </td> <td> - <div>Authorization type.</div> + <div>Authorization type (ro=read-only, rw=read-write).</div> </td> </tr> <tr> @@ -207,7 +207,7 @@ Parameters <td> </td> <td> - <div>IP address.</div> + <div>IP address to listen on.</div> </td> </tr> <tr> @@ -308,6 +308,7 @@ Parameters <td> </td> <td> + <div>SNMPv3 group configuration.</div> </td> </tr> <tr> @@ -326,6 +327,7 @@ Parameters <td> </td> <td> + <div>Group name.</div> </td> </tr> <tr> @@ -347,6 +349,7 @@ Parameters </ul> </td> <td> + <div>Access mode (ro=read-only, rw=read-write).</div> </td> </tr> <tr> @@ -368,6 +371,7 @@ Parameters </ul> </td> <td> + <div>Minimum security level required for group members.</div> </td> </tr> <tr> @@ -385,6 +389,7 @@ Parameters <td> </td> <td> + <div>View name the group has access to.</div> </td> </tr> @@ -403,6 +408,7 @@ Parameters <td> </td> <td> + <div>SNMPv3 trap target configuration.</div> </td> </tr> <tr> @@ -420,6 +426,7 @@ Parameters <td> </td> <td> + <div>IP address of the SNMPv3 trap target.</div> </td> </tr> <tr> @@ -437,6 +444,7 @@ Parameters <td> </td> <td> + <div>Authentication parameters for trap target.</div> </td> </tr> <tr> @@ -455,6 +463,7 @@ Parameters <td> </td> <td> + <div>Encrypted authentication key.</div> </td> </tr> <tr> @@ -473,6 +482,7 @@ Parameters <td> </td> <td> + <div>Plaintext authentication key.</div> </td> </tr> <tr> @@ -491,6 +501,7 @@ Parameters <td> </td> <td> + <div>Authentication algorithm.</div> </td> </tr> @@ -509,6 +520,7 @@ Parameters <td> </td> <td> + <div>UDP port on the trap target host.</div> </td> </tr> <tr> @@ -526,6 +538,7 @@ Parameters <td> </td> <td> + <div>Privacy parameters for trap target.</div> </td> </tr> <tr> @@ -544,6 +557,7 @@ Parameters <td> </td> <td> + <div>Encrypted privacy key.</div> </td> </tr> <tr> @@ -562,6 +576,7 @@ Parameters <td> </td> <td> + <div>Plaintext privacy key.</div> </td> </tr> <tr> @@ -580,6 +595,7 @@ Parameters <td> </td> <td> + <div>Privacy algorithm.</div> </td> </tr> @@ -602,6 +618,7 @@ Parameters </ul> </td> <td> + <div>Transport protocol for traps.</div> </td> </tr> <tr> @@ -623,6 +640,7 @@ Parameters </ul> </td> <td> + <div>Trap type.</div> </td> </tr> @@ -641,6 +659,7 @@ Parameters <td> </td> <td> + <div>SNMPv3 user configuration.</div> </td> </tr> <tr> @@ -658,6 +677,7 @@ Parameters <td> </td> <td> + <div>Authentication parameters for this user.</div> </td> </tr> <tr> @@ -676,7 +696,7 @@ Parameters <td> </td> <td> - <div>Encrypted key (stored as encrypted-password on device).</div> + <div>Encrypted authentication key (stored as encrypted-password on device).</div> </td> </tr> <tr> @@ -695,7 +715,7 @@ Parameters <td> </td> <td> - <div>Plaintext key (device encrypts it; recommended for 1.5+).</div> + <div>Plaintext authentication key (device encrypts it).</div> </td> </tr> <tr> @@ -712,12 +732,9 @@ Parameters </div> </td> <td> - <ul style="margin: 0; padding: 0"><b>Choices:</b> - <li>md5</li> - <li>sha</li> - </ul> </td> <td> + <div>Authentication algorithm.</div> </td> </tr> @@ -736,6 +753,7 @@ Parameters <td> </td> <td> + <div>Group this user belongs to.</div> </td> </tr> <tr> @@ -757,6 +775,7 @@ Parameters </ul> </td> <td> + <div>Access mode for this user.</div> </td> </tr> <tr> @@ -774,6 +793,7 @@ Parameters <td> </td> <td> + <div>Privacy (encryption) parameters for this user.</div> </td> </tr> <tr> @@ -792,6 +812,7 @@ Parameters <td> </td> <td> + <div>Encrypted privacy key.</div> </td> </tr> <tr> @@ -810,6 +831,7 @@ Parameters <td> </td> <td> + <div>Plaintext privacy key (device encrypts it).</div> </td> </tr> <tr> @@ -826,12 +848,9 @@ Parameters </div> </td> <td> - <ul style="margin: 0; padding: 0"><b>Choices:</b> - <li>des</li> - <li>aes</li> - </ul> </td> <td> + <div>Privacy algorithm.</div> </td> </tr> @@ -850,6 +869,7 @@ Parameters <td> </td> <td> + <div>TSM fingerprint of the certificate mapped to this user.</div> </td> </tr> <tr> @@ -868,6 +888,7 @@ Parameters <td> </td> <td> + <div>Username.</div> </td> </tr> @@ -886,6 +907,7 @@ Parameters <td> </td> <td> + <div>SNMPv3 view configuration.</div> </td> </tr> <tr> @@ -903,6 +925,7 @@ Parameters <td> </td> <td> + <div>OID subtree excluded from this view.</div> </td> </tr> <tr> @@ -920,6 +943,7 @@ Parameters <td> </td> <td> + <div>OID mask for the view.</div> </td> </tr> <tr> @@ -937,6 +961,7 @@ Parameters <td> </td> <td> + <div>OID subtree included in this view.</div> </td> </tr> <tr> @@ -955,6 +980,7 @@ Parameters <td> </td> <td> + <div>View name.</div> </td> </tr> @@ -1005,6 +1031,7 @@ Parameters <td> </td> <td> + <div>IP address of the trap target host.</div> </td> </tr> <tr> @@ -1021,6 +1048,7 @@ Parameters <td> </td> <td> + <div>Community name to use for traps.</div> </td> </tr> <tr> @@ -1037,6 +1065,7 @@ Parameters <td> </td> <td> + <div>UDP port on the trap target host.</div> </td> </tr> 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( |
