From 7ab78ebe57fc6681ae297a9a33a0bb7435a2146f Mon Sep 17 00:00:00 2001 From: Lars Beckers <lars.beckers@rwth-aachen.de> Date: Mon, 15 Mar 2021 14:40:05 +0100 Subject: [PATCH] basic-system: adapt logrotate configuration to bullseye --- basic-system/defaults/main.yml | 2 ++ basic-system/templates/logrotate.conf.j2 | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/basic-system/defaults/main.yml b/basic-system/defaults/main.yml index 262bb4a..70f0523 100644 --- a/basic-system/defaults/main.yml +++ b/basic-system/defaults/main.yml @@ -7,4 +7,6 @@ etckeeper: true rsyslog_needed: false hosts_precious: false journal_persitent_with_package: true +logrotate_period: 'daily' # 'weekly' is newer default +logrotate_backlogs: 7 # default is 7 for daily, 4 for weekly common_sysctl_file: '/etc/sysctl.conf' diff --git a/basic-system/templates/logrotate.conf.j2 b/basic-system/templates/logrotate.conf.j2 index 2be8fd5..b25502e 100644 --- a/basic-system/templates/logrotate.conf.j2 +++ b/basic-system/templates/logrotate.conf.j2 @@ -1,13 +1,19 @@ # see "man logrotate" for details -# rotate log files daily -daily -# keep 7 days worth of backlogs -rotate 7 +# global options do not affect preceding include directives + +# rotate log files {{ logrotate_period }} +{{ logrotate_period }} + +# keep {{ logrotate_backlogs }} {{ 'weeks' if logrotate_period == 'weekly' else 'days' }} worth of backlogs +rotate {{ logrotate_backlogs }} # create new (empty) log files after rotating old ones create +# use date as a suffix of the rotated file +#dateext + # uncomment this if you want your log files compressed compress delaycompress @@ -15,7 +21,7 @@ delaycompress # packages drop log rotation information into this directory include /etc/logrotate.d -{% if ansible_distribution_major_version|int < 10 %} +{% if ansible_distribution_major_version|int(default=99) < 10 %} # no packages own wtmp, or btmp -- we'll rotate them here /var/log/wtmp { missingok @@ -32,4 +38,4 @@ include /etc/logrotate.d } {% endif %} -# system-specific logs may be configured here +# system-specific logs may also be configured here. -- GitLab