saucelabs-ansible.logrotate

logrotate

Build Status

Installs logrotate and provides an easy way to setup additional logrotate scripts by specifying a list of directives.

Requirements

None

Tests

Family Distribution Version Test Status
Debian Ubuntu Precise x86 x86_64
Debian Ubuntu Trusty x86 x86_64
Debian Ubuntu Vivid x86 x86_64
Debian Ubuntu Wily x86 x86_64

Role Variables

  • logrotate_version: the logrotate version to be installed (default: *).
  • logrotate_scripts: list of logrotate scripts and the directives to use for the rotation, each list element should have the following keys:
    • name: name of the script that goes into /etc/logrotate.d/
    • path: list of paths which need log rotation
    • options: list of directives for logrotate, view the logrotate man page for specifics
    • scripts: dictionary of scripts for logrotate (see Example below)
logrotate_scripts:
  - name: rails
    path:
      - /srv/current/log/*.log
    options:
      - weekly
      - size 25M
      - missingok
      - compress
      - delaycompress
      - copytruncate

Dependencies

None

Example Playbook

Setting up logrotate for additional Nginx logs, with postrotate script.

- name: some play
  hosts: some-group
  gather_facts: yes

  roles:
    - role: logrotate
      logrotate_scripts:
        - name: nginx
          path:
            - /var/log/nginx/*.log
          options:
            - weekly
            - size 25M
            - rotate 7
            - missingok
            - compress
            - delaycompress
            - copytruncate
          scripts:
            postrotate: |
              [test -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
              # ability to add more lines to this section
      tags: logrotate

License

BSD

Author Information

About

Role to setup logrotate on a server.

Install
ansible-galaxy install saucelabs-ansible.logrotate
GitHub repository
License
bsd-3-clause
Downloads
71