diff options
Diffstat (limited to 'plugins')
4 files changed, 76 insertions, 12 deletions
diff --git a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py index 0be49e51..734d190e 100644 --- a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py @@ -175,6 +175,8 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "file_num": {"type": "int"}, "size": {"type": "int"}, }, + "removed_in_version": "7.0.0", + "removed_from_collection": "vyos.vyos", }, "facilities": { "type": "list", @@ -282,10 +284,16 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "protocol": { "type": "str", "choices": ["udp", "tcp"], + "removed_in_version": "7.0.0", + "removed_from_collection": "vyos.vyos", }, }, }, "hostname": {"type": "str"}, + "protocol": { + "type": "str", + "choices": ["udp", "tcp"], + }, }, }, "syslog": { diff --git a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py index d8bfa182..f94c9195 100644 --- a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py @@ -59,6 +59,8 @@ class Logging_global(ResourceModule): "files.archive.file_num", "files", "hosts.port", + "hosts.facility.protocol", # 1.3 and below + "hosts.protocol", "hosts", "users", ] diff --git a/plugins/module_utils/network/vyos/rm_templates/logging_global.py b/plugins/module_utils/network/vyos/rm_templates/logging_global.py index 6c692cfd..516e270b 100644 --- a/plugins/module_utils/network/vyos/rm_templates/logging_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/logging_global.py @@ -28,7 +28,7 @@ def tmplt_params(config_data): tmplt += " facility {facility}".format(facility=val["facility"]) if val.get("severity"): tmplt += " level {level}".format(level=val["severity"]) - if val.get("protocol"): + elif val.get("protocol"): tmplt += " protocol {protocol}".format(protocol=val["protocol"]) return tmplt @@ -50,7 +50,12 @@ def tmplt_params(config_data): tmplt = templt_common(val.get("facilities"), tmplt) elif config_data.get("hosts"): val = config_data.get("hosts") - if val.get("hostname") and not val.get("archive") and not val.get("port"): + if ( + val.get("hostname") + and not val.get("archive") + and not val.get("port") + and not val.get("protocol") + ): tmplt += "system syslog host {hostname}".format(hostname=val["hostname"]) if val.get("facilities"): tmplt = templt_common(val.get("facilities"), tmplt) @@ -352,6 +357,51 @@ class Logging_globalTemplate(NetworkTemplate): }, }, { + "name": "hosts.protocol", + "getval": re.compile( + r""" + ^set\ssystem\ssyslog\shost + (\s(?P<hostname>\S+)) + (\sprotocol\s(?P<protocol>'(udp|tcp)')) + $""", re.VERBOSE, + ), + "setval": "system syslog host {{ hosts.hostname }} protocol {{ hosts.protocol }}", + "result": { + "hosts": { + "{{ hostname }}": { + "hostname": "{{ hostname }}", + "protocol": "{{ protocol }}", + }, + }, + }, + }, + { + # Version 1.3 and below + "name": "hosts.facility.protocol", + "getval": re.compile( + r""" + ^set\ssystem\ssyslog\shost + (\s(?P<hostname>\S+)) + (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7])) + (\sprotocol\s(?P<protocol>'(udp|tcp)')) + $""", re.VERBOSE, + ), + "setval": "system syslog host {{ hosts.hostname }} facility {{ hosts.facility }} protocol {{ hosts.protocol }}", + "remval": "system syslog host {{ hosts.hostname }} facility {{ hosts.facility }} protocol {{ hosts.protocol }}", + "result": { + "hosts": { + "{{ hostname }}": { + "hostname": "{{ hostname }}", + "facilities": [ + { + "facility": "{{ facility }}", + "protocol": "{{ protocol }}", + }, ], + }, + }, + }, + }, + { "name": "hosts", "getval": re.compile( r""" @@ -359,7 +409,6 @@ class Logging_globalTemplate(NetworkTemplate): (\s(?P<hostname>\S+)) (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7])) (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? - (\sprotocol\s(?P<protocol>'(udp|tcp)'))? $""", re.VERBOSE, ), "setval": tmplt_params, @@ -372,7 +421,6 @@ class Logging_globalTemplate(NetworkTemplate): { "facility": "{{ facility }}", "severity": "{{ level }}", - "protocol": "{{ protocol }}", }, ], }, }, diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py index 069d5080..9479e7b2 100644 --- a/plugins/modules/vyos_logging_global.py +++ b/plugins/modules/vyos_logging_global.py @@ -20,7 +20,7 @@ short_description: Logging resource module description: This module manages the logging attributes of Vyos network devices author: Sagar Paul (@KB-perByte) notes: - - Tested against vyos 1.2 + - Tested against vyos 1.3.8+ - This module works with connection C(network_cli). - The Configuration defaults of the Vyos network devices are supposed to hinder idempotent behavior of plays @@ -139,7 +139,7 @@ options: facility: *facility severity: *severity protocol: - description: syslog communication protocol + description: syslog communication protocol. Version 1.3 and below. type: str choices: - udp @@ -147,6 +147,12 @@ options: hostname: description: Remote host name or IP address type: str + protocol: + description: syslog communication protocol. Version 1.4+ + type: str + choices: + - udp + - tcp syslog: description: logging syslog type: dict @@ -715,17 +721,17 @@ commands: returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - - "set system syslog console facility local7 level err" - - "set system syslog host 172.16.0.1 port 223" - - "set system syslog global archive size 111" + - set system syslog console facility local7 level err + - set system syslog host 172.16.0.1 port 223 + - set system syslog global archive size 111 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 system syslog host 172.16.0.1 port 223" - - "set system syslog user vyos facility local7 level debug" - - "set system syslog global facility cron level debug" + - set system syslog host 172.16.0.1 port 223 + - set system syslog user vyos facility local7 level debug + - set system syslog global facility cron level debu gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) |