2019-11-03 17:31:08 +00:00
|
|
|
---
|
|
|
|
- name: disable default rules
|
|
|
|
set_fact:
|
|
|
|
rsyslog_default_rules_state: absent
|
|
|
|
when: rsyslog_archival_format_enabled
|
|
|
|
|
2019-12-04 02:14:59 +00:00
|
|
|
- name: configure systemd tmpfiles.d
|
|
|
|
template:
|
|
|
|
src: tmpfiles_d-rsyslog.conf
|
|
|
|
dest: /etc/tmpfiles.d/00rsyslog.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
when: rsyslog_archival_format_enabled
|
|
|
|
|
|
|
|
- name: manage systemd tmpfiles.d override
|
|
|
|
file:
|
|
|
|
path: /etc/tmpfiles.d/00rsyslog.conf
|
|
|
|
state: "{{ rsyslog_archival_format_enabled | ternary('file', 'absent') }}"
|
|
|
|
|
2019-11-22 03:41:29 +00:00
|
|
|
- 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
|
|
|
|
|
2019-12-04 02:14:07 +00:00
|
|
|
- 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 }}"
|
2019-11-03 17:31:08 +00:00
|
|
|
|
2019-11-22 03:41:29 +00:00
|
|
|
- name: delete logrotate configuration
|
2019-11-03 17:31:08 +00:00
|
|
|
file:
|
2019-11-22 03:41:29 +00:00
|
|
|
path: /etc/logrotate.d/rsyslog
|
|
|
|
state: absent
|
|
|
|
when: rsyslog_archival_format_enabled
|
2019-11-03 17:31:08 +00:00
|
|
|
|
2019-11-23 03:08:34 +00:00
|
|
|
- name: create /var/log/syslog
|
|
|
|
file:
|
|
|
|
path: /var/log/syslog
|
2019-12-04 02:41:50 +00:00
|
|
|
owner: "{{ rsyslog_dir_owner }}"
|
|
|
|
group: "{{ rsyslog_dir_group }}"
|
|
|
|
mode: "{{ rsyslog_dir_create_mode }}"
|
2019-11-23 03:08:34 +00:00
|
|
|
state: directory
|
|
|
|
|
2019-11-03 17:31:08 +00:00
|
|
|
- name: configure archival format
|
|
|
|
template:
|
|
|
|
src: archival.conf.j2
|
|
|
|
dest: /etc/rsyslog.d/10-archival.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify: restart rsyslog
|
|
|
|
when: rsyslog_archival_format_enabled
|
|
|
|
|
|
|
|
- name: manage archive rules
|
|
|
|
file:
|
|
|
|
path: /etc/rsyslog.d/10-archival.conf
|
|
|
|
state: "{{ rsyslog_archival_format_enabled | ternary('file', 'absent') }}"
|
|
|
|
|
|
|
|
- name: compress log cron job
|
|
|
|
cron:
|
|
|
|
name: compress syslog
|
|
|
|
minute: "0"
|
|
|
|
hour: "1"
|
|
|
|
user: root
|
2022-08-30 11:49:11 +00:00
|
|
|
job: find /var/log/syslog/ -mindepth 4 -type f -name "*.log" ! -newerct 00:00:00 -exec nice xz -f {} \;
|
2020-09-21 03:24:49 +00:00
|
|
|
state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}"
|
|
|
|
|
|
|
|
- name: purge log cron job
|
|
|
|
cron:
|
|
|
|
name: purge syslog
|
|
|
|
minute: "0"
|
|
|
|
hour: "2"
|
|
|
|
user: root
|
2020-10-10 16:00:32 +00:00
|
|
|
job: >
|
|
|
|
find /var/log/syslog/ -mindepth 4 -type f -name "*.log.xz" -mtime +90 -delete &&
|
|
|
|
find /var/log/syslog/ -mindepth 3 -type d -empty -delete
|
2019-11-03 17:31:08 +00:00
|
|
|
state: "{{ rsyslog_archival_format_enabled | ternary('present', 'absent') }}"
|