salt.modules.logrotate

Module for managing logrotate.

salt.modules.logrotate.get(key, value=None, conf_file='/etc/logrotate.conf')

Get the value for a specific configuration line.

Parameters:
  • key (str) -- The command or stanza block to configure.
  • value (str) -- The command value or command of the block specified by the key parameter.
  • conf_file (str) -- The logrotate configuration file.
Returns:

The value for a specific configuration line.

Return type:

bool|int|str

CLI Example:

salt '*' logrotate.get rotate

salt '*' logrotate.get /var/log/wtmp rotate /etc/logrotate.conf
salt.modules.logrotate.set(key, value, setting=None, conf_file='/etc/logrotate.conf')

Set a new value for a specific configuration line.

Parameters:
  • key (str) -- The command or block to configure.
  • value (str) -- The command value or command of the block specified by the key parameter.
  • setting (str) -- The command value for the command specified by the value parameter.
  • conf_file (str) -- The logrotate configuration file.
Returns:

A boolean representing whether all changes succeeded.

Return type:

bool

CLI Example:

salt '*' logrotate.set rotate 2

Can also be used to set a single value inside a multiline configuration block. For instance, to change rotate in the following block:

/var/log/wtmp {
    monthly
    create 0664 root root
    rotate 1
}

Use the following command:

salt '*' logrotate.set /var/log/wtmp rotate 2

This module also has the ability to scan files inside an include directory, and make changes in the appropriate file.

salt.modules.logrotate.show_conf(conf_file='/etc/logrotate.conf')

Show parsed configuration

Parameters:conf_file (str) -- The logrotate configuration file.
Returns:The parsed configuration.
Return type:dict

CLI Example:

salt '*' logrotate.show_conf