diff --git a/basic-system/defaults/main.yml b/basic-system/defaults/main.yml index 262bb4ae1d8108d84e5dc57e1f5b5273b10c4395..70f052396f56d79f536f441c60f7f994b4b0d23b 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 2be8fd5c7b8c4bfe8edf52150d96df9343ea9a70..b25502e9588be402b1b527f4a67389af5811a8c1 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.