Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.
/ ansible-logrotate Public archive

ansible role to install and configure logrotate. provides an easy way to setup additional logrotate scripts by specifying a list of directives.

License

Notifications You must be signed in to change notification settings

bodsch/ansible-logrotate

Repository files navigation

Ansible Role: logrotate

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.


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

Requirements & Dependencies

Ansible Collections

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 no longer officially supported! May work, but does not have to.

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

logroate_disable_systemd: true

logrotate_scripts: A dictionary of logrotate scripts and the directives to use for the rotation.

  • state - create (present) or remove (absent) configuration. default: present
  • path - Path to point logrotate to for the log rotation
  • paths - A list of paths to point logrotate to for the log rotation.
  • options - List of directives for logrotate, view the logrotate man page for specifics
  • scripts - 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)

Example Playbook

see into molecule test and configuration

Contribution

Please read Contribution

Development, Branches (Git Tags)

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!

Author

  • Bodo Schulz

License

Apache

FREE SOFTWARE, HELL YEAH!

About

ansible role to install and configure logrotate. provides an easy way to setup additional logrotate scripts by specifying a list of directives.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published