summaryrefslogtreecommitdiff
path: root/src/conf_mode/system_syslog.py
diff options
context:
space:
mode:
authorAdam Schultz <adam.schultz@live.com>2026-01-24 09:55:14 -0500
committerAdam Schultz <adam.schultz@live.com>2026-02-09 22:59:37 -0500
commit696df602557dd7b70b353c3b9cfb110c0908a2fe (patch)
treed7ec98633981069f21b0af09575bf1e53cf79f56 /src/conf_mode/system_syslog.py
parent9707b90b9ddacd27b74ef235a6f5a8f585c2bc50 (diff)
downloadvyos-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/conf_mode/system_syslog.py')
-rwxr-xr-xsrc/conf_mode/system_syslog.py20
1 files changed, 15 insertions, 5 deletions
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):