cookbook 'logrotate', '= 2.3.0'
logrotate
(50) Versions
2.3.0
-
-
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
Follow149
- 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', '= 2.3.0', :supermarket
knife supermarket install logrotate
knife supermarket download logrotate
logrotate Cookbook
Manages the logrotate package and provides a resource to manage application specific logrotate configuration.
Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.
Requirements
Platforms
Should work on any platform that includes a 'logrotate' package and writes logrotate configuration to /etc/logrotate.d.
Tested on:
- Ubuntu / Debian
- CentOS
- Amazon Linux
- openSUSE Leap
Chef
- Chef 12.5+
Cookbooks
- none
Recipes
global
Generates and controls a global /etc/logrotate.conf
file that will include additional files generated by the logrotate_app
resource (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
resource) 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 }
Resources
logrotate_app
This resource can be used to drop off customized logrotate config files on a per application basis.
The resource takes the following properties:
-
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. -
cookbook
: The cookbook that continues the template for logrotate_app config resources. By default this islogrotate
. Users can provide their own template by setting this attribute to point at a different cookbook. -
template_name
: sets the template source, default is "logrotate.erb". -
template_mode
: the mode to create the logrotate template with (default: "0644") -
template_owner
: the owner of the logrotate template (default: "root") -
template_group
: the group of the logrotate template (default: "root") -
frequency
: sets the frequency for rotation. Default value is 'weekly'. Valid values are: hourly, daily, weekly, monthly, yearly, see the logrotate man page for more information. Note that usually logrotate is configured to be run by cron daily. You have to change this configuration and run logrotate hourly to be able to really rotate logs hourly. Hourly rotation requires logrotate v3.8.5 or higher. -
options
: Any logrotate configuration option that doesn't specify a value. See the logrotate(8) manual page of v3.9.2 or earlier for details.
In addition to these properties, any logrotate option that takes a parameter can be used as a logrotate_app property. For example, to set the rotate
option you can use a resource declaration such as:
logrotate_app 'tomcat-myapp' do path '/var/log/tomcat/myapp.log' frequency 'daily' rotate 30 create '644 root adm' end
Also, any logrotate option that takes one of scripts names (firstaction
, prerotate
, postrotate
, and lastaction
) can be used. Script body should be passed as value of this option. For example, nginx logrotation with postrotate
:
logrotate_app 'nginx' do path '/var/log/nginx/*.log' frequency 'daily' options %w(missingok compress delaycompress notifempty dateext dateyesterday nomail sharedscripts) rotate 365 create '640 www-data www-data' dateformat '.%Y-%m-%d' maxage 365 postrotate '[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`' end
See the logrotate(8) manual page of v3.9.2 or earlier for the list of available options.
Usage
The default recipe will ensure logrotate is always up to date.
To create application specific logrotate configs, use the logrotate_app
resource. 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 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 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 path '/var/log/tomcat/myapp.log' options ['missingok', 'delaycompress', 'notifempty'] frequency 'daily' rotate 30 create '644 root adm' end
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers!
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
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
2.3.0 - 2021-02-10
- Sous Chefs Adoption
- Fix cookstyle issues
- mdl and yamlint fixes
- Audit kitchen platforms
2.2.3 (2020-06-02)
- Remove opensuse platform from metadata.rb as it's no longer valid - @tas50
- Don't fail on deprecated properties - @tas50
- Require Chef 12.15+ - @tas50
- Standardise files with files in chef-cookbooks/repo-management - @xorimabot
- Resolved deprecations to provide Chef Infra Client 16 compatibility - @xorimabot
- Resolved cookstyle error: resources/app.rb:17:1 warning:
ChefDeprecations/ResourceUsesOnlyResourceName
2.2.2 (2019-10-01)
- Update build badge with chef-cookbooks namespace - @jasonwbarnett
- Use our standard delivery config and stop testing with Foodcritic - @tas50
- Switch the maintainer over to Chef Software - @tas50
- Remove deprecated metadata fields - @tas50
- Remove ChefSpec matchers that are autogenerated now - @tas50
- Use Ubuntu 18.04 in the specs not 16.04 - @tas50
- Update the kitchen configs with the latest platforms - @tas50
- Add updated testing.md and contributing.md files - @tas50
2.2.1 (2019-10-01)
- Avoid deprecation warnings in the chefspecs - @tas50
- Resolve foodcritic license warning - @tas50
- There's no need to define a default action in a custom resource - @tas50
- Move templates out of default dir and remove node name - @tas50
- Remove the mention of Ruby 2.0 in the contributing docs - @tas50
- Add initial kitchen-dokken config - @tas50
- Use our standard chefignore file - @tas50
- Rename fake recipe to test and definitions -> resources - @tas50
- Convert to inspec from serverspec - @tas50
- Remove the default test kitchen suite since global includes it - @tas50
- Remove references to the definition from the metadata - @tas50
- Expand platforms we test on in Test Kitchen - @tas50
- Remove unused prep recipe - @tas50
- Add suse platforms to the metadata now that we test them - @tas50
- Format readme and remove references to the definition - @tas50
- Fix alignment for multiple scripts - @shoekstra
- Ignore FC109 - @shoekstra
- Update /var/log/btmp default permissions - @jasonwbarnett
2.2.0
- The
compat_resource
dependency was removed. This means we now require Chef 12.5 or higher. It also means we now better support Chef 13. - The global configuration now supports scripts.
- The package install action (upgrade by default) is now configurable via an attribute.
- The development environment now more closely follows modern cookbook practices.
- ChefSpec matcher now correctly calls ChefSpec.define_matcher.
2.1.0
- Restore
cookbook
parameter forlogrotate_app
resource due to popular demand. - Add a
template_name
parameter to replace the 1.xtemplate
parameter. The nametemplate
can't be used inside a resource without conflicting with an attribute of the same name. - Fix exception when
options
specified as a string rather than an array
2.0.0
- Convert the logrotate_app definition to a resource
- Accept all options included in logrotate 3.9.2
- The
cookbook
parameter tologrotate_app
is no longer accepted.
1.9.2
- Fix deprecation warnings from ChefSpec
1.9.1
- Fixes regression in the sharedscripts logrotate_app parameter (Bug #69)
1.9.0
- All configuration options from the logrotate 3.8.8 manual page can be used by the global configuration and the logrotate_app definition.
- Berkshelf is no longer a development dependency of the logrotate cookbook.
- Rubocop lint failures have been resolved.
1.8.0
-
su
parameter now supported in global config. - 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.
1.7.0
- Use
raise
rather than Application.fatal! to prevent killing a daemonized chef-client - Chefspec matcher for logrotate_app definition
- Support the following options: compressoptions, maxage, shred/shredcycles, extension, tabooext
- Add Solaris support
1.6.0
- Fix documentation error
- Support for options "compresscmd", "uncompresscmd", "compressext"
- Allow nodateext as parameter for logrotate_app definition
- Move to chefspec ~> 3.0
1.5.0
- Fix missing end tag in template
- Don't re-initialize constants.
- Fix rubocop finding
- [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
1.4.0
- 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
- COOK-2646 - Add ability to choose file mode for logrotate template
1.3.0
-
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
COOK-3274 - Fix README typo that suggested the opposite action
COOK-2923 - Add
olddir
optionCOOK-1651 - Add
dateext
ability
1.2.2
- [COOK-2872]: Add firstaction/lastaction ability to logrotate
- [COOK-2908]: Argument error in
logrotate_app
definition
1.2.0
- [COOK-2401] - Add the ability to manage the global logrotate configuration
1.1.0
- [COOK-2218] - Logrotate size parameter
1.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