Add excludes to logrotate.d config and update to correct paths
This commit is contained in:
parent
4a11950728
commit
fd04a750a5
8
roles/common/defaults/main.yml
Normal file
8
roles/common/defaults/main.yml
Normal 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"
|
@ -81,16 +81,24 @@
|
|||||||
paths: "/etc/logrotate.d/"
|
paths: "/etc/logrotate.d/"
|
||||||
register: "logrotateconfigs"
|
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:
|
replace:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: "(?:weekly|monthly)"
|
regexp: "(?:weekly|monthly)"
|
||||||
replace: "daily"
|
replace: "daily"
|
||||||
loop: "{{ logrotateconfigs.files }}"
|
loop: "{{ logrotateconfigpaths }}"
|
||||||
|
|
||||||
- name: Set logrotate.conf rotation to 7
|
- name: 'Set /etc/logrotate.d/* rotation to 7'
|
||||||
replace:
|
replace:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: "rotate [0-9]+"
|
regexp: "rotate [0-9]+"
|
||||||
replace: "rotate 7"
|
replace: "rotate 7"
|
||||||
loop: "{{ logrotateconfigs.files }}"
|
loop: "{{ logrotateconfigpaths }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user