2021-01-23 14:25:35 +01:00
|
|
|
---
|
|
|
|
# Install and configure logrotate
|
|
|
|
|
|
|
|
# Install the apt package
|
|
|
|
name: Install logrotate
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- logrotate
|
|
|
|
|
|
|
|
# Copy the configuration and reload the service if it has changed
|
|
|
|
- name: Configure logrotate
|
|
|
|
template:
|
|
|
|
src: logrotate.d/rsyslog.j2
|
|
|
|
dst: /etc/logrotate.d/rsyslog
|
|
|
|
owner: root
|
|
|
|
groupe: root
|
|
|
|
mode: "0644"
|
|
|
|
notify: restart logrotate
|
|
|
|
|
|
|
|
# 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
|
|
|
|
command: logrotate -f /etc/logrotate.d/rsyslog
|