diff options
| author | Adam Schultz <adam.schultz@live.com> | 2026-01-24 09:55:14 -0500 |
|---|---|---|
| committer | Adam Schultz <adam.schultz@live.com> | 2026-02-09 22:59:37 -0500 |
| commit | 696df602557dd7b70b353c3b9cfb110c0908a2fe (patch) | |
| tree | d7ec98633981069f21b0af09575bf1e53cf79f56 /src | |
| parent | 9707b90b9ddacd27b74ef235a6f5a8f585c2bc50 (diff) | |
| download | vyos-1x-696df602557dd7b70b353c3b9cfb110c0908a2fe.tar.gz vyos-1x-696df602557dd7b70b353c3b9cfb110c0908a2fe.zip | |
T7756: Fix rsyslog configuration generation
1.) Fix both syslog and logrotate writing /etc/logrotate.d/vyos-rsyslog
- system_syslog.py generates /etc/logrotate.d/vyos-rsyslog-user for user file
logrotate
- system_logs.py generates /etc/logrotate.d/vyos-rsyslog using configured
rotation parameters
2.) Fix /run/rsyslog/rsyslog.conf ignoring configured size for /var/log/messages
- system_syslog.py retrieves "system logs" config to set rotation limits
- default rotation size is now based on configuration defaults
3.) prifilt strings for rsyslog are modified to use override syntax
(e.g. ";facility.none") when all is combined with other facilities to honor
per facility user intent
Smoke test changes:
Commonize configuration of syslog facilities
Check that prifilt is sane based on configured facilities (i.e. overides only
present when required)
Test wildcard (all) only, specific facility only, and wildcard + specific facility
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/system_logs.py | 8 | ||||
| -rwxr-xr-x | src/conf_mode/system_syslog.py | 20 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/conf_mode/system_logs.py b/src/conf_mode/system_logs.py index f0e742d1b..f31986034 100755 --- a/src/conf_mode/system_logs.py +++ b/src/conf_mode/system_logs.py @@ -19,6 +19,8 @@ from sys import exit from vyos import ConfigError from vyos import airbag from vyos.config import Config +from vyos.configdep import set_dependents +from vyos.configdep import call_dependents from vyos.logger import syslog from vyos.template import render from vyos.utils.dict import dict_search @@ -35,6 +37,8 @@ def get_config(config=None): else: conf = Config() + set_dependents('syslog', conf) + base = ['system', 'logs'] logs_config = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True, @@ -64,8 +68,8 @@ def generate(logs_config): def apply(logs_config): - # No further actions needed - pass + # Ensure dependent config scripts (e.g., syslog) are re-run + call_dependents() if __name__ == '__main__': diff --git a/src/conf_mode/system_syslog.py b/src/conf_mode/system_syslog.py index 90bb45c51..7e5b4f90c 100755 --- a/src/conf_mode/system_syslog.py +++ b/src/conf_mode/system_syslog.py @@ -40,7 +40,8 @@ airbag.enable() cert_dir = '/etc/rsyslog.d/certs' rsyslog_conf = '/run/rsyslog/rsyslog.conf' -logrotate_conf = '/etc/logrotate.d/vyos-rsyslog' +logrotate_user_conf = '/etc/logrotate.d/vyos-rsyslog-user' +logrotate_messages_conf = '/etc/logrotate.d/vyos-rsyslog' systemd_socket = 'syslog.socket' systemd_service = systemd_services['syslog'] @@ -124,7 +125,16 @@ def get_config(config=None): with_pki=True, ) - syslog.update({ 'logrotate' : logrotate_conf }) + syslog.update({ 'logrotate' : logrotate_messages_conf }) + + logs_config = conf.get_config_dict( + ['system', 'logs'], + key_mangling=('-', '_'), + get_first_key=True, + with_recursive_defaults=True, + ) + max_size_mb = dict_search('logrotate.messages.max_size', logs_config) + syslog['logrotate_size_limit'] = int(max_size_mb) * 1024 * 1024 syslog = conf.merge_defaults(syslog, recursive=True) if syslog.from_defaults(['local']): @@ -192,8 +202,8 @@ def generate(syslog): if not syslog: if os.path.exists(rsyslog_conf): os.unlink(rsyslog_conf) - if os.path.exists(logrotate_conf): - os.unlink(logrotate_conf) + if os.path.exists(logrotate_user_conf): + os.unlink(logrotate_user_conf) return None @@ -203,7 +213,7 @@ def generate(syslog): _save_tls_certificates_for_remote(syslog, remote_options) render(rsyslog_conf, 'rsyslog/rsyslog.conf.j2', syslog) - render(logrotate_conf, 'rsyslog/logrotate.j2', syslog) + render(logrotate_user_conf, 'rsyslog/logrotate.j2', syslog) return None def apply(syslog): |
