diff options
-rw-r--r-- | data/templates/syslog/override.conf.tmpl | 11 | ||||
-rw-r--r-- | interface-definitions/system-syslog.xml.in | 1 | ||||
-rwxr-xr-x | src/conf_mode/system-syslog.py | 29 |
3 files changed, 34 insertions, 7 deletions
diff --git a/data/templates/syslog/override.conf.tmpl b/data/templates/syslog/override.conf.tmpl new file mode 100644 index 000000000..60c397fa7 --- /dev/null +++ b/data/templates/syslog/override.conf.tmpl @@ -0,0 +1,11 @@ +{% set vrf_command = 'ip vrf exec ' + vrf + ' ' if vrf is defined else '' %} +[Unit] +StartLimitIntervalSec=0 + +[Service] +ExecStart= +ExecStart={{ vrf_command }}/usr/sbin/rsyslogd -n -iNONE +Restart=always +RestartPreventExitStatus= +RestartSec=10 +RuntimeDirectoryPreserve=yes diff --git a/interface-definitions/system-syslog.xml.in b/interface-definitions/system-syslog.xml.in index f3dcae2f3..6d0feba33 100644 --- a/interface-definitions/system-syslog.xml.in +++ b/interface-definitions/system-syslog.xml.in @@ -955,6 +955,7 @@ </tagNode> </children> </node> + #include <include/interface/vrf.xml.i> </children> </node> </children> diff --git a/src/conf_mode/system-syslog.py b/src/conf_mode/system-syslog.py index 3d8a51cd8..030192ec2 100755 --- a/src/conf_mode/system-syslog.py +++ b/src/conf_mode/system-syslog.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2018-2020 VyOS maintainers and contributors +# Copyright (C) 2018-2023 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -20,8 +20,11 @@ import re from sys import exit from vyos.config import Config +from vyos.configdict import is_node_changed +from vyos.configverify import verify_vrf from vyos import ConfigError from vyos.util import run +from vyos.util import call from vyos.template import render from vyos import airbag @@ -38,9 +41,9 @@ def get_config(config=None): config_data = { 'files': {}, - 'console': {}, - 'hosts': {}, - 'user': {} + 'console': {}, + 'hosts': {}, + 'user': {} } # @@ -80,7 +83,6 @@ def get_config(config=None): # # set system syslog file # - if c.exists('file'): filenames = c.list_nodes('file') for filename in filenames: @@ -164,6 +166,9 @@ def get_config(config=None): } ) + if c.exists('vrf'): + config_data.update({'vrf' : c.return_value('vrf')}) + return config_data @@ -210,6 +215,11 @@ def generate(c): conf = '/etc/logrotate.d/vyos-rsyslog' render(conf, 'syslog/logrotate.tmpl', c) + conf = r'/etc/systemd/system/rsyslog.service.d/override.conf' + render(conf, 'syslog/override.conf.tmpl', c) + + # Reload systemd manager configuration + call('systemctl daemon-reload') def verify(c): if c == None: @@ -221,8 +231,11 @@ def verify(c): # if not os.path.islink('/etc/rsyslog.conf'): os.remove('/etc/rsyslog.conf') - os.symlink( - '/usr/share/vyos/templates/rsyslog/rsyslog.conf', '/etc/rsyslog.conf') + os.symlink('/usr/share/vyos/templates/rsyslog/rsyslog.conf', + '/etc/rsyslog.conf') + + + verify_vrf(c) # /var/log/vyos-rsyslog were the old files, we may want to clean those up, but currently there # is a chance that someone still needs it, so I don't automatically remove @@ -240,6 +253,8 @@ def verify(c): for conf in c: if c[conf]: + if conf == 'vrf': + continue for item in c[conf]: for s in c[conf][item]['selectors'].split(";"): f = re.sub("\..*$", "", s) |