2021-01-23 14:25:35 +01:00
|
|
|
---
|
|
|
|
# Install and configure logrotate
|
|
|
|
|
|
|
|
# Install the apt package
|
2021-01-23 14:41:25 +01:00
|
|
|
- name: Install logrotate
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- logrotate
|
2021-01-23 14:25:35 +01:00
|
|
|
|
|
|
|
# Copy the configuration and reload the service if it has changed
|
|
|
|
- name: Configure logrotate
|
|
|
|
template:
|
|
|
|
src: logrotate.d/rsyslog.j2
|
2021-01-23 15:42:52 +01:00
|
|
|
dest: /etc/logrotate.d/rsyslog
|
2021-01-23 14:25:35 +01:00
|
|
|
owner: root
|
2021-01-23 15:59:03 +01:00
|
|
|
group: root
|
2021-01-23 14:25:35 +01:00
|
|
|
mode: "0644"
|
2021-01-23 16:02:10 +01:00
|
|
|
notify: restart logrotate
|
2021-01-23 14:25:35 +01:00
|
|
|
|
|
|
|
# Make sure the service is enabled and started
|
|
|
|
- name: Enable logrotate service
|
|
|
|
service:
|
|
|
|
name: logrotate
|
|
|
|
enabled: true
|
|
|
|
state: started
|
2021-01-23 14:27:09 +01:00
|
|
|
|
|
|
|
# Enforce new logrotate rules now
|
|
|
|
- name: Run logrotate now
|
2021-01-23 14:37:18 +01:00
|
|
|
command: /usr/sbin/logrotate -f /etc/logrotate.d/rsyslog
|