Forge Home

logrotate

manages logrotate

31,314 downloads

11,754 latest version

4.6 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.1.39 (latest)
  • 0.1.37
  • 0.1.36
  • 0.1.35
  • 0.1.34
  • 0.1.33
  • 0.1.32
  • 0.1.31
  • 0.1.30
  • 0.1.29
  • 0.1.28
  • 0.1.27
  • 0.1.26
released Feb 8th 2019
This version is compatible with:
  • , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'eyp-logrotate', '0.1.39'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add eyp-logrotate
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install eyp-logrotate --version 0.1.39

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

eyp/logrotate — version 0.1.39 Feb 8th 2019

logrotate

Table of Contents

  1. Overview
  2. Module Description
  3. Setup
  4. Usage
  5. Reference
  6. Limitations
  7. Development

Overview

logrotate configuration

Module Description

manages logrotate configuration files

Setup

What logrotate affects

Manages:

  • logrotate package
  • files and directories:
    • /etc/logrotate.conf
    • /etc/logrotate.d/puppet-managed

Setup Requirements

This module requires pluginsync enabled

Beginning with logrotate

logrotates:
  nginxlogs:
    log: /LOGS/web/*.log
    rotate: 2
    frequency: daily
    notifempty: true
    compress: true
    missingok: true
    dateext: true
    postrotate: /etc/init.d/nginx reload
  opt_openresty_nginx_logs:
    log:
      - /opt/openresty/nginx/logs/access.log
      - /opt/openresty/nginx/logs/error.log
    rotate: 2
    frequency: daily
    notifempty: true
    compress: true
    missingok: true
    dateext: true
    postrotate: /etc/init.d/nginx reload

Usage

example usage:

class { 'logrotate': }

logrotate::logs { 'example':
  create_mode => '0777',
  rotate      => '3',
  log         => [ '/var/example/log1', '/var/example/log2' ],
}

logrotate::logs { 'bitban1':
  log           => '/deploy/VAR/local/systemadmin/www.systemadmin.es/BB3Logs/*log*',
  su            => [ 'bbt-deploy', 'bbt-deploy' ],
  rotate        => '2',
  frequency     => 'daily',
  notifempty    => true,
  compress      => true,
  delaycompress => true,
  missingok     => true,
}

logrotate::logs { 'rotatnginx':
  log        => '/LOGS/web/*.log',
  rotate     => '2',
  frequency  => 'daily',
  notifempty => true,
  compress   => true,
  missingok  => true,
  postrotate => '/etc/init.d/nginx reload',
}

puppet managed configuration files

This is going to generate the following logrotate configuration files:

/etc/logrotate.d/puppet-managed/rotatnginx

/LOGS/web/*.log {
  rotate 2
  daily
  notifempty
  compress
  missingok
  postrotate
    /etc/init.d/nginx reload
  endscript
}

/etc/logrotate.d/puppet-managed/demo

/deploy/VAR/local/systemadmin/www.systemadmin.es/BB3Logs/*log* {
  su bbt-deploy bbt-deploy
  rotate 2
  daily
  notifempty
  compress
  delaycompress
  missingok
}

/etc/logrotate.d/puppet-managed/example

/var/example/log1 /var/example/log2 {
  create 0777 root root
  rotate 3
}

Reference

classes

logrotate

  • ensure: package status (default: installed)
  • overwrite_default_logrotate_conf: (default: true)
  • default behaviour:
    • compress: compress log files (default: true)
    • dateext: use date as a suffix of the rotated file (default: true)
    • create: create new (empty) log files after rotating old ones (default: true)
    • rotate: keep rotations worth of backlogs (default: 4)
    • frequency: log rotation frequency (default: weekly)

defines

logrotate::logs

  • log: log files to rotate (it can be an array or string)
  • namelog: (default: resource's name)
  • ensure: log rotation config file presence (default: present)
  • su: array, change ownership (default: undef)
  • rotate: keep rotations worth of backlogs (default: undef)
  • maxage: Remove rotated logs older than maxage days (default: undef)
  • compress: compress log files (default: undef)
  • delaycompress: Postpone compression of the previous log file to the next rotation cycle (default: undef)
  • notifempty: Do not rotate if file is empty (default: undef)
  • frequency: log rotation frequency (default: undef)
  • missingok: If the log file is missing, go on to the next one without issuing an error message (default: undef)
  • postrotate: post rotation action (default: undef)
  • dateext: use date as a suffix of the rotated file (default: false)
  • copytruncate: Truncate the original log file to zero size in place after creating a copy (default: false)
  • size: Log files are rotated only if they grow bigger then size bytes (default: undef)
  • create_mode: file creation mode, if create_owner and/or create_group are defined, defaults to 0640 (default: undef)
  • create_owner: file creation owner, if create_mode and/or create_group are defined, defaults to root (default: undef)
  • create_group: file creation group, if create_mode and/or create_group are defined, defaults to root (default: undef)
  • custom_file: create log file rotation on a custom file path (default: undef)
  • sharedscripts: is set to true, the postrotate script will only be run once (after the old logs have been compressed), not once for each log which is rotated (default: false)

Limitations

Tested on:

  • Ubuntu 14.04
  • CentOS 5
  • CentOS 6
  • CentOS 7

Development

We are pushing to have acceptance testing in place, so any new feature must have tests to check both presence and absence of any feature

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request