diff --git a/roles/rsyslog/tasks/archival.yaml b/roles/rsyslog/tasks/archival.yaml index 08b1c57..102b52c 100644 --- a/roles/rsyslog/tasks/archival.yaml +++ b/roles/rsyslog/tasks/archival.yaml @@ -68,5 +68,14 @@ minute: "0" hour: "1" user: root - job: find /var/log/syslog/ -type f -name "*.log" -mtime +5 -exec xz {} \; + job: find /var/log/syslog/ -mindepth 4 -type f -name "*.log" -mtime +5 -exec xz {} \; + state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}" + +- name: purge log cron job + cron: + name: purge syslog + minute: "0" + hour: "2" + user: root + job: find /var/log/syslog/ -mindepth 4 -type f -name "*.log" -mtime +90 -delete state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}"