diff --git a/roles/rocky9/tasks/logrotate.yml b/roles/rocky9/tasks/logrotate.yml new file mode 100644 index 0000000..b726ab0 --- /dev/null +++ b/roles/rocky9/tasks/logrotate.yml @@ -0,0 +1,7 @@ +- name: Set logrotate rsyslog + ansible.builtin.template: + src: logrotate-rsyslog.j2 + dest: /etc/logrotate.d/rsyslog + mode: "0644" + owner: root + group: root diff --git a/roles/rocky9/templates/logrotate-rsyslog.j2 b/roles/rocky9/templates/logrotate-rsyslog.j2 new file mode 100644 index 0000000..4d5d772 --- /dev/null +++ b/roles/rocky9/templates/logrotate-rsyslog.j2 @@ -0,0 +1,65 @@ +/var/log/cron { + daily + rotate {{ logrotate_interval }} + size 50M + compress + delaycompress + missingok + notifempty + sharedscripts + postrotate + /usr/bin/systemctl reload rsyslog.service 2> /dev/null || true + endscript +} +/var/log/maillog { + daily + rotate {{ logrotate_interval }} + size 50M + compress + delaycompress + missingok + notifempty + sharedscripts + postrotate + /usr/bin/systemctl reload rsyslog.service 2> /dev/null || true + endscript +} +/var/log/secure { + daily + rotate {{ logrotate_interval }} + size 50M + compress + delaycompress + missingok + notifempty + sharedscripts + postrotate + /usr/bin/systemctl reload rsyslog.service 2> /dev/null || true + endscript +} +/var/log/spooler +{ + daily + rotate {{ logrotate_interval }} + compress + missingok + notifempty + sharedscripts + postrotate + /usr/bin/systemctl -s HUP kill rsyslog.service >/dev/null 2>&1 || true + endscript +} + +/var/log/messages { + daily + rotate {{ logrotate_interval }} + size 50M + compress + delaycompress + missingok + notifempty + sharedscripts + postrotate + /usr/bin/systemctl reload rsyslog.service 2> /dev/null || true + endscript +}