bodsch.logrotate

Ansible Role: logrotate

This role installs logrotate and makes it easy to set up extra logrotate scripts by listing the instructions you want to use.


The development of this Ansible role has been moved to the Collection bodsch.core. This repository will not be actively maintained anymore.


GitHub Workflow Status GitHub issues GitHub release (latest by date) Ansible Quality Score

Requirements & Dependencies

Ansible Collections

To install, run:

ansible-galaxy collection install bodsch.core

or

ansible-galaxy collection install --requirements-file collections.yml

Operating Systems

Tested on:

  • ArchLinux
  • Debian-based
    • Debian 10 / 11 / 12
    • Ubuntu 20.04 / 22.04

RedHat-based systems are not officially supported anymore! It might work, but there's no guarantee.

Usage

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: {}

logrotate_disable_systemd: true

logrotate_scripts: A list of logrotate scripts and their instructions.

  • state - create (present) or remove (absent) configuration. Default: present
  • path - The path for logrotate to manage logs.
  • paths - A list of paths for logrotate to manage logs.
  • options - List of instructions for logrotate. Check the logrotate manual for details.
  • scripts - A dictionary of scripts for logrotate (see examples below).

Example Logrotate Script Configurations

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)

Example Playbook

Check the molecule test and configuration.

Contribution

Please refer to Contribution.

Development, Branches (Git Tags)

The master branch is my Working Horse that contains the newest features and may be unstable!

If you want something reliable, please use a Tagged Version.

Author

  • Bodo Schulz

License

Apache

FREE SOFTWARE, HELL YEAH!

Informazioni sul progetto

Role to configure logrotate scripts

Installa
ansible-galaxy install bodsch.logrotate
Licenza
apache-2.0
Download
4.3k
Proprietario
ex-developer (c, c++, php), ex-system administrator / engineer, keep-it-simple, monitoring, automation, system architect