cookbook 'logrotate', '= 1.9.0'
logrotate
(51) Versions
1.9.0
-
-
3.0.27
-
3.0.25
-
3.0.24
-
3.0.23
-
3.0.22
-
3.0.21
-
3.0.20
-
3.0.19
-
3.0.18
-
3.0.17
-
3.0.16
-
3.0.15
-
3.0.14
-
3.0.13
-
3.0.12
-
3.0.11
-
3.0.10
-
3.0.9
-
3.0.8
-
3.0.7
-
3.0.6
-
3.0.5
-
3.0.4
-
3.0.3
-
3.0.2
-
3.0.1
-
3.0.0
-
2.3.0
-
2.2.3
-
2.2.2
-
2.2.1
-
2.2.0
-
2.1.0
-
2.0.0
-
1.9.2
-
1.9.1
-
1.9.0
-
1.8.0
-
1.7.0
-
1.6.0
-
1.5.0
-
1.4.0
-
1.3.0
-
1.2.2
-
1.2.0
-
1.1.0
-
1.0.2
-
1.0.0
-
0.8.2
-
0.8.1
-
0.7.0
Follow148
- 3.0.27
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.2
- 1.2.0
- 1.1.0
- 1.0.2
- 1.0.0
- 0.8.2
- 0.8.1
- 0.7.0
Installs logrotate package and provides a resource for managing logrotate configs
cookbook 'logrotate', '= 1.9.0', :supermarket
knife supermarket install logrotate
knife supermarket download logrotate
logrotate Cookbook
Manages the logrotate package and provides a definition to manage application specific logrotate configuration.
Requirements
Should work on any platform that includes a 'logrotate' package and writes logrotate configuration to /etc/logrotate.d. Tested on Ubuntu, Debian and Red Hat/CentOS.
Recipes
global
Generates and controls a global /etc/logrotate.conf
file that will include additional files generated by the logrotate_app
definition (see below). The contents of the configuration file is controlled through node attributes under node['logrotate']['global']
. The default attributes are based on the configuration from the Ubuntu logrotate package.
To define a valueless directive (e.g. compress
, copy
) simply add an attribute named for the directive with a truthy value :
node['logrotate']['global']['compress'] = 'any value here'
Note that defining a valueless directive with a falsey value will not make it false, but will remove it:
# Removes a defaulted 'compress' directive; does not add a 'nocompress' directive. node.override['logrotate']['global']['compress'] = false
To fully override a booleanish directive like compress
, you should probably remove the positive form and add the negative form:
node.override['logrotate']['global']['compress'] = false node.override['logrotate']['global']['nocompress'] = true
The same is true of frequency directives; to be certain the frequency directive you want is included in the global configuration, you should override the ones you don't want as false:
%w[ daily weekly yearly ].each do |freq| node.override['logrotate']['global'][freq] = false end node.override['logrotate']['global']['monthly'] = true
To define a parameter with a value (e.g. create
, mail
) add an attribute with the desired value:
node['logrotate']['global']['create'] = '0644 root adm'
To define a path stanza in the global configuration (generally unneeded because of the logrotate_app
definition) just add an attribute with the path as the name and a hash containing directives and parameters as described above:
node['logrotate']['global']['/var/log/wtmp'] = { 'missingok' => true, 'monthly' => true, 'create' => '0660 root utmp', 'rotate' => 1 }
firstaction
, prerotate
, postrotate
, and lastaction
scripts can be defined either as arrays of the lines to put in the script or multiline strings:
node['logrotate']['global']['/var/log/foo/*.log'] = { 'missingok' => true, 'monthly' => true, 'create' => '0660 root adm', 'rotate' => 1, 'prerotate' => ['service foo start_rotate', 'logger started foo service log rotation'], 'postrotate' => <<-EOF service foo end_rotate logger completed foo service log rotation EOF }
Definitions
logrotate_app
This definition can be used to drop off customized logrotate config files on a per application basis.
The definition takes the following params:
-
path
: specifies a single path (string) or multiple paths (array) that should have logrotation stanzas created in the config file. No default, this must be specified. -
enable
: true/false, if true it will create the template in /etc/logrotate.d. -
frequency
: sets the frequency for rotation. Default value is 'weekly'. Valid values are: daily, weekly, monthly, yearly, see the logrotate man page for more information. -
dateformat
: specifies date extension with %Y, %m, %d, and %s. The default value is -%Y%m%d. -
size
: Log files are rotated when they grow bigger than size bytes. -
maxsize
: Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval. -
su
: Rotate log files set under this user and group instead of using default user/group. -
template
: sets the template source, default is "logrotate.erb". -
template_mode
: the mode to create the logrotate template with (default "0440") -
template_owner
: the owner of the logrotate template (default "root") -
template_group
: the group of the logrotate template (default "root") -
cookbook
: select the template source from the specified cookbook. By default it will use the template from the logrotate cookbook. -
create
: creation parameters for the logrotate "create" config, follows the form "mode owner group". This is an optional parameter, and is nil by default. -
firstaction
: lines to be executed once before all log files that match the wildcarded pattern are rotated, before pre-rotate script is run and only if at least one log will actually be rotated -
postrotate
: lines to be executed after the log file is rotated -
prerotate
: lines to be executed before the log file is rotated -
lastaction
: lines to be executed once after all log files that match the wildcarded pattern are rotated, after postrotate script is run and only if at least one log is rotated -
rotate
: Log files are rotated this many times before being removed or mailed. -
sharedscripts
: if true, the sharedscripts options is specified which makes sure prescript and postscript commands are run only once (even if multiple files match the path)
Usage
The default recipe will ensure logrotate is always up to date.
To create application specific logrotate configs, use the logrotate_app
definition. For example, to rotate logs for a tomcat application named myapp that writes its log file to /var/log/tomcat/myapp.log
:
logrotate_app 'tomcat-myapp' do cookbook 'logrotate' path '/var/log/tomcat/myapp.log' frequency 'daily' rotate 30 create '644 root adm' end
To rotate multiple logfile paths, specify the path as an array:
logrotate_app 'tomcat-myapp' do cookbook 'logrotate' path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out'] frequency 'daily' create '644 root adm' rotate 7 end
To specify which logrotate options, specify the options as an array:
logrotate_app 'tomcat-myapp' do cookbook 'logrotate' path '/var/log/tomcat/myapp.log' options ['missingok', 'delaycompress', 'notifempty'] frequency 'daily' rotate 30 create '644 root adm' end
License & Authors
- Author:: Scott M. Likens (scott@likens.us)
- Author:: Joshua Timberman (joshua@chef.io)
Copyright 2009, Scott M. Likens Copyright 2011-2012, Chef Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
logrotate Cookbook CHANGELOG
This file is used to list changes made in each version of the
logrotate cookbook.
v1.8.0
Resolved Bugs
-
su
parameter now supported in global config.
Improvements
- firstaction and lastaction attributes documented in the README
- rotate attribute documented in the README
- Use hash-rocket syntax in rspec matcher to maintain 1.9 support.
v1.7.0
Bugs
- Use
raise
rather than Application.fatal! to prevent killing a daemonized chef-client
Improvements
- Chefspec matcher for logrotate_app definition
- Support the following options: compressoptions, maxage, shred/shredcycles, extension, tabooext
- Add Solaris support
v1.6.0
Bugs
- Fix documentation error
Improvements
- Support for options "compresscmd", "uncompresscmd", "compressext"
- Allow nodateext as parameter for logrotate_app definition
- Move to chefspec ~> 3.0
v1.5.0
Bugs
- Fix missing end tag in template
- Don't re-initialize constants.
- Fix rubocop finding
Improvements
- [COOK-3911] Allow to use maxsize parameter.
- [COOK-4000] Allow to use dateyesterday option.
- [COOK-4024] Allow to use su parameter.
- [COOK-4175] Allows use of the dateformat parameter.
- Loosen test-kitchen version constraint
- Add rvm files to gitignore
v1.4.0
Bug
- COOK-3632 - Raise Exception when adding more than one invalid option
- COOK-3141 - Do not duplicate template entires for multiple paths
- COOK-3034 - Update logrotate_app params to accept arrays and strings
Improvement
- COOK-2646 - Add ability to choose file mode for logrotate template
v1.3.0
Improvement
-
COOK-3341 - Add optional
frequency
androtate
params when defined globally -
COOK-3298 - Use
Array
instead ofrespond_to?(:each)
-
COOK-3285 - Change
logrotate.d
config file mode to0644
-
COOK-3250 - Add
minsize
Bug
- COOK-3274 - Fix README typo that suggested the opposite action
New Feature
v1.2.2
Bug
- [COOK-2872]: Add firstaction/lastaction ability to logrotate
- [COOK-2908]: Argument error in
logrotate_app
definition
v1.2.0
- [COOK-2401] - Add the ability to manage the global logrotate configuration
v1.1.0
- [COOK-2218] - Logrotate size parameter
v1.0.2
- [COOK-1027] - Add support for pre-/post-rotate commands
- [COOK-1338] - Update log rotate for more flexibility of rotate options
- [COOK-1598] - "Create" isn't a mandatory option
Foodcritic Metric
1.9.0 failed this metric
FC015: Consider converting definition to a LWRP: /tmp/cook/8981ce9a3adc59b9bd03344e/logrotate/definitions/logrotate_app.rb:1
1.9.0 failed this metric