forked from evolix/ansible-roles
Ludovic Poujol
dc1c78e08a
I've noticed that some log files, especially /var/log/syslog were empty. After investigating, I've realized that it was happening after a log rotation by logrotate. The old mechanism, `invoke-rc.d rsyslog rotate` isn't working anymore on Debian 10. It will fail with a not so explicit message : [FAIL] Closing open files: rsyslogd failed! Long story short, it seems that the pid file (`/run/rsyslogd.pid`) isn't created any more, so start-stop-daemon as used by /etc/init.d/rsyslog will fail. Explaining the error message. Debian 10 rsyslog now brings `/usr/lib/rsyslog/rsyslog-rotate` that is used by logrotate. It will send the signal HUP the 'right' way, so rsyslog will be aware of the log rotation. Sadly, this script isn't present in Debian 9 nor 8, so the logrotate configuration for rsyslog is now a template, using the right command for the right version.
41 lines
986 B
YAML
41 lines
986 B
YAML
---
|
|
|
|
# TODO: voir comment faire des backups initiaux des fichiers
|
|
|
|
- name: Copy rsyslog.conf
|
|
copy:
|
|
src: logs/rsyslog.conf
|
|
dest: /etc/rsyslog.conf
|
|
mode: "0644"
|
|
notify: restart rsyslog
|
|
when: evolinux_logs_rsyslog_conf
|
|
|
|
- name: Disable logrotate default conf
|
|
command: mv /etc/logrotate.d/rsyslog /etc/logrotate.d/rsyslog.disabled
|
|
args:
|
|
removes: /etc/logrotate.d/rsyslog
|
|
creates: /etc/logrotate.d/rsyslog.disabled
|
|
notify: restart rsyslog
|
|
when: evolinux_logs_disable_logrotate_rsyslog
|
|
|
|
- name: Copy many logrotate files
|
|
copy:
|
|
src: logs/logrotate.d/
|
|
dest: /etc/logrotate.d/
|
|
when: evolinux_logs_logrotate_confs
|
|
|
|
- name: Copy rsyslog logrotate file
|
|
template:
|
|
src: logs/zsyslog.j2
|
|
dest: /etc/logrotate.d/zsyslog
|
|
when: evolinux_logs_logrotate_confs
|
|
|
|
- name: Configure logrotate.conf
|
|
replace:
|
|
dest: /etc/logrotate.conf
|
|
regexp: "rotate [0-9]+"
|
|
replace: "rotate 12"
|
|
when: evolinux_logs_default_rotate
|
|
|
|
- meta: flush_handlers
|