Installs logrotate and provides an easy way to setup additional logrotate scripts by specifying a list of directives.
Further development of this Ansible role has been moved to Collection bodsch.core. This repository will therefore no longer be actively maintained.
Ansible Collections
ansible-galaxy collection install bodsch.core
or
ansible-galaxy collection install --requirements-file collections.yml
Tested on
- ArchLinux
- Debian based
- Debian 10 / 11 / 12
- Ubuntu 20.04 / 22.04
RedHat-based systems are no longer officially supported! May work, but does not have to.
logrotate_global:
rotate_log: weekly
rotate_size: ''
su_user: ''
su_group: ''
rotate: 2
create: true
dateext: true
compress: true
tabooext: []
archive_directory: ''
logrotate_conf_dir: "/etc/logrotate.d"
logrotate_scripts: {}
logroate_disable_systemd: true
state
- create (present
) or remove (absent
) configuration. default:present
path
- Path to point logrotate to for the log rotationpaths
- A list of paths to point logrotate to for the log rotation.options
- List of directives for logrotate, view the logrotate man page for specificsscripts
- Dict of scripts for logrotate (see Example below)
logrotate_scripts:
audit:
path: /var/log/audit/audit.log
description: |
rotate all audit logs
options:
- weekly
- rotate 4
- missingok
- notifempty
- delaycompress
scripts:
prerotate: systemctl stop auditd.service > /dev/null
postrotate: systemctl start auditd.service > /dev/null
foo: failed
logrotate_scripts:
nginx:
paths:
- /var/log/nginx/*/*.log
- /var/log/nginx/*.log
options:
- weekly
- rotate 2
- missingok
- notifempty
- compress
- sharedscripts
- create 0644 http log
- su root http
scripts:
postrotate: test ! -r /run/nginx.pid || kill -USR1 $(cat /run/nginx.pid)
see into molecule test and configuration
Please read Contribution
The master
Branch is my Working Horse includes the "latest, hot shit" and can be complete broken!
If you want to use something stable, please use a Tagged Version!
- Bodo Schulz
FREE SOFTWARE, HELL YEAH!