darkwizard242.logrotate
Ansible Role: logrotate
Role to install (by default) logrotate package or uninstall (if passed as var) as well as configure for any number of logrotate configurations on Debian based and EL based systems.
Requirements
None.
Role Variables
Available variables are listed below (located in defaults/main.yml):
Variables list:
logrotate_app: logrotate
logrotate_desired_state: present
logrotate_config_dir: /etc/logrotate.d
logrotate_configs: []
logrotate_template: conf.j2
Variables table:
| Variable | Description |
|---|---|
| logrotate_app | Defines the app to install i.e. logrotate |
| logrotate_desired_state | Defined to dynamically chose whether to install (i.e. either present or latest) or uninstall (i.e. absent) the package. Defaults to present. |
| logrotate_config_dir | Directory to place logrotate configuration into i.e. /etc/logrotate.d |
| logrotate_configs | Pass desired logrotate configurations. Playbook example provided. |
| logrotate_template | Template used as source. |
Dependencies
None
Example Playbook
For default behaviour of role (i.e. installation of logrotate package) in ansible playbooks.
- hosts: servers
roles:
- darkwizard242.logrotate
For customizing behavior of role (i.e. custom config of logrotate ) in ansible playbooks.
- hosts: servers
roles:
- darkwizard242.logrotate
vars:
logrotate_configs:
- name: ansible
path: /var/log/ansible.log
options:
- weekly
- create 0644 root root
- size 10M
- rotate 5
- dateext
- dateformat -%Y_%m_%d
- notifempty
- missingok
- compress
- delaycompress
- copytruncate
For customizing behavior of role (i.e. custom config and postrotate scripts of logrotate ) in ansible playbooks.
- hosts: servers
roles:
- darkwizard242.logrotate
vars:
logrotate_configs:
- name: ansible
path: /var/log/ansible.log
options:
- weekly
- create 0644 root root
- size 10M
- rotate 5
- dateext
- dateformat -%Y_%m_%d
- notifempty
- missingok
- compress
- delaycompress
- copytruncate
- name: ansible-script
path: /var/log/ansible.log
options:
- weekly
- create 0644 root root
- size 10M
- rotate 5
- dateext
- dateformat -%Y_%m_%d
- notifempty
- missingok
- compress
- delaycompress
- copytruncate
scripts:
postrotate: 'echo "Ansible log has been rotated" > ~/rotation.txt'
License
Author Information
This role was created by Ali Muhammad.
About
Dynamically installs/uninstalls 'logrotate' package and sets up configurations.
Install
ansible-galaxy install darkwizard242.logrotateLicense
mit
Downloads
4.8k
Owner
Senior DevOps/CloudOps Engineer.
Dedicated to Automating everything I come across.
Love to work on and learn new technologies/tools everyday!
