ansible/roles/logrotate/tasks/main.yml

34 lines
661 B
YAML

---
# Install the apt package
- name: Install logrotate
apt:
name:
- logrotate
state: present
- name: Create rsyslog configuration directory
file:
path: /etc/rsyslog.d
owner: root
group: root
mode: u=rwx,g=rx,o=rx
- name: Configure logrotate
template:
src: logrotate.conf
dest: /etc/logrotate.conf
owner: root
group: root
mode: u=rwx,g=r,o=r
notify: Reload logrotate
- name: Enable logrotate service
systemd:
name: logrotate.service
enabled: true
state: started
# Enforce new logrotate rules now
- name: Run logrotate now
command: /usr/sbin/logrotate -f /etc/logrotate.d/rsyslog
...