Install logrotate package.
This role requires Ansible 2.8 or higher, and platform requirements are listed in the metadata file.
This role use Molecule to run tests.
Local and Github Actions tests run tests on Docker by default. See molecule documentation to use other backend.
Currently, tests are done on:
- CentOS 7
- CentOS 8
- Debian Buster
- Debian Stretch
- Ubuntu Bionic
- Ubuntu Focal
and use:
- Ansible 2.8.x
- Ansible 2.9.x
$ tox
You can also configure molecule options and molecule command using environment variables:
MOLECULE_OPTIONSDefault: "--debug"MOLECULE_COMMANDDefault: "test"
$ MOLECULE_OPTIONS='' MOLECULE_COMMAND=converge tox
# Defaults vars file for logrotate role
logrotate_packages: "{{ _logrotate_packages }}"
logrotate_repository_cache_valid_time: 3600
logrotate_repository_install_recommends: False
# Configuration paths
logrotate_conf_d_dir:
path: '/etc/logrotate.d'
owner: 'root'
group: 'root'
mode: '0755'
logrotate_conf_main_file:
path: '/etc/logrotate.conf'
owner: 'root'
group: 'root'
mode: '0644'
# Configuration content
logrotate_main_config: |
weekly
su root syslog
rotate 4
create
include {{ logrotate_conf_d_dir.path }}
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
logrotate_items: []You can define easily new logrotate items, the will be stored in logrotate_conf_d_dir.path.
logrotate_items:
- name: 'my_app'
content: |
"/var/log/my_app.log" {
daily
missingok
rotate 54
compress
delaycompress
notifempty
create 640 root root
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}None
- hosts: servers
roles:
- { role: infOpen.logrotate }MIT
Alexandre Chaussier (for Infopen company)
- https://www.infopen.pro
- a.chaussier [at] infopen.pro