From c8ac7c5f0a8c1cce2ee975a3e893e429a0f2a42b Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Thu, 21 Nov 2019 21:41:29 -0600 Subject: [PATCH] Remove rsyslog logrotate job, remove default log files --- roles/rsyslog/tasks/archival.yaml | 28 ++++++++++++++++++---------- roles/rsyslog/vars/Debian.yaml | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/roles/rsyslog/tasks/archival.yaml b/roles/rsyslog/tasks/archival.yaml index 8678bdc..53aaa8e 100644 --- a/roles/rsyslog/tasks/archival.yaml +++ b/roles/rsyslog/tasks/archival.yaml @@ -4,18 +4,26 @@ rsyslog_default_rules_state: absent when: rsyslog_archival_format_enabled -- name: check status of /var/log/syslog - stat: - path: /var/log/syslog - register: st +- name: find default log files + find: + path: /var/log + file_type: file + pattern: "{{ rsyslog_default_log_patterns }}" + when: rsyslog_archival_format_enabled + register: default_log_files -- name: delete files +- name: delete files + file: + path: "{{ item.path }}" + state: "{{ rsyslog_archival_format_enabled | ternary('absent', 'file') }}" + when: rsyslog_archival_format_enabled + with_items: "{{ default_log_files.files }}" + +- name: delete logrotate configuration file: - path: "{{ item }}" - state: "{{ rsyslog_archival_format_enabled | ternary('absent', 'file') }}" - when: rsyslog_archival_format_enabled and st.stat.exists and st.stat.isreg - with_items: - - /var/log/syslog + path: /etc/logrotate.d/rsyslog + state: absent + when: rsyslog_archival_format_enabled - name: configure archival format template: diff --git a/roles/rsyslog/vars/Debian.yaml b/roles/rsyslog/vars/Debian.yaml index d1aa04b..6e92402 100644 --- a/roles/rsyslog/vars/Debian.yaml +++ b/roles/rsyslog/vars/Debian.yaml @@ -14,3 +14,18 @@ rsyslog_default_rules: - "mail.* -/var/log/mail.log" - "mail.err /var/log/mail.err" - "*.emerg :omusrmsg:*" + +rsyslog_default_log_patterns: + - auth.log* + - cron.log* + - daemon.log* + - debug* + - kern.log* + - lpr.log* + - mail.err* + - mail.info* + - mail.log* + - mail.warn* + - messages* + - syslog* + - user.log*