gabops.logrotate
gabops.logrotate
This role installs and sets up logrotate.
Requirements
None required.
Role Variables
Variable | Default Value | Description |
---|---|---|
logrotate_packages | [] | List of packages to install logrotate. This role already manages package installation, but you can specify your own list here if needed. |
logrotate_enable_repo | "" | The repository to enable when installing packages from logrotate_packages . This only works with RedHat family distributions. |
logrotate_config_global | [] | Configuration settings for /etc/logrotate.conf . If left empty (the default), this file won't be changed. |
logrotate_config_files | [] | Individual logrotate configurations to apply. Refer to Notes and Example Playbook for details. |
Notes:
- Configurations in
logrotate_config_files
will be applied in the directory/etc/logrotate.d
unless you use theinclude
directive inlogrotate_config_global
. For example:
logrotate_config_global:
- include
- weekly
- rotate 4
- create
- dateext
- include /etc/customdir
This setup tells the role to use the custom path instead of the default.
Each configuration in
logrotate_config_files
will create an individual file named as specified in thename
field.Each entry in
logrotate_config_files
needs the following:
logrotate_config_files:
- name: "" # => Required.
state: "" # => Optional: use 'present' or 'absent'. Defaults to 'present' if not specified.
path: "" # => Required (can be a string or a list).
directives: "" # => Required.
Dependencies
None.
Example Playbook
- hosts: servers
vars:
logrotate_config_global:
- weekly
- rotate 4
- create
- dateext
- include /etc/logrotate.d
logrotate_config_files:
- name: messages
state: absent
path: /var/log/messages
directives: |
rotate 5
weekly
postrotate
/usr/bin/killall -HUP syslogd
endscript
- name: httpd
path:
- /var/log/httpd/access.log
- /var/log/httpd/error.log
directives: |
rotate 5
mail [email protected]
size 100k
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
endscript
roles:
- role: gabops.logrotate
License
Author Information
Gabriel Suarez (Gabops)
Informazioni sul progetto
Installs and configures logrotate.
Installa
ansible-galaxy install gabops.logrotate
Licenza
mit
Download
25.5k
Proprietario
I am a DevOps engineer who likes Python, Go, AWS, Kubernetes and climbing with friends.