Add excludes to logrotate.d config and update to correct paths

This commit is contained in:
Kishi85 2020-02-04 15:01:13 +01:00 committed by Markus Hauschild
parent 4a11950728
commit fd04a750a5
2 changed files with 20 additions and 4 deletions

View File

@ -0,0 +1,8 @@
---
logrotate_excludes:
- "/etc/logrotate.d/alternatives"
- "/etc/logrotate.d/apt"
- "/etc/logrotate.d/dpkg"
- "/etc/logrotate.d/dbconfig-common"
- "/etc/logrotate.d/btmp"
- "/etc/logrotate.d/wtmp"

View File

@ -81,16 +81,24 @@
paths: "/etc/logrotate.d/"
register: "logrotateconfigs"
- name: Set logrotate.d/* to daily
- name: Convert found files to path list
set_fact:
alllogrotateconfigpaths: "{{ logrotateconfigs.files | map(attribute='path') | list }}"
- name: Exclude files from ansible management
set_fact:
logrotateconfigpaths: "{{ alllogrotateconfigpaths | difference(logrotate_excludes) }}"
- name: 'Set logrotate.d/* to daily'
replace:
path: "{{ item }}"
regexp: "(?:weekly|monthly)"
replace: "daily"
loop: "{{ logrotateconfigs.files }}"
loop: "{{ logrotateconfigpaths }}"
- name: Set logrotate.conf rotation to 7
- name: 'Set /etc/logrotate.d/* rotation to 7'
replace:
path: "{{ item }}"
regexp: "rotate [0-9]+"
replace: "rotate 7"
loop: "{{ logrotateconfigs.files }}"
loop: "{{ logrotateconfigpaths }}"