Remove rsyslog logrotate job, remove default log files

This commit is contained in:
Ryan Cavicchioni 2019-11-21 21:41:29 -06:00
parent b8d6c5a3f7
commit c8ac7c5f0a
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 33 additions and 10 deletions

View File

@ -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:

View File

@ -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*