Installs/configures Ken Salter's LogRotate for Windows.
This is a Windows implementation of the logrotate utility found in Linux platforms.
Supported logrotate configuration options: https://sourceforge.net/p/logrotatewin/wiki/LogRotate/#configuration-file
- Chef 12.6+
- .NET Framework v4.5
- Windows
Use windows_logrotate resource to install and configure logrotate, and create a scheduled task to run it periodically.
Example
windows_logrotate 'logrotate test' do
username user
password pass
run_immediately true
sensitive false
conf <<-EOF
C:\\test.log {
missingok
compress
delaycompress
copytruncate
notifempty
rotate 5
daily
prerotate
@echo off
echo This is a test
echo parameter pass %1
VER | TIME > TEMP.BAT
ECHO SET TIME=%%3>CURRENT.BAT
DEL TEMP.BAT
DEL CURRENT.BAT
ECHO It's %TIME% now
endscript
}
EOF
end
name
- The name of logrotate configuration file to create. Defaults to resource block name.username
- The username to create scheduled task as. Default:Administrator
.password
- Required to create scheduled task.conf
- Required logroate configuration.verbose
- Turns on verbose mode. Sensitive will need to be false in order to see output.force
- Tells logrotate to force the rotation, even if it doesn't think this is necessary. Sometimes this is useful after adding new entries to a logrotate config file, or if old log files have been removed by hand, as the new files will be created, and logging will continue correctly.run_immediately
- Runs scheduled task immediately after creating or updating logrotate configuration.cookbook
- The cookbook that contains the template for logrotate conf. Users can provide their own template by setting this attribute to point at a different cookbook. Default:windows_logrotate
.conf_tmpl
- Sets the conf template source. Default:logrotate.conf.erb
.schtask_tmpl
- Sets the schtask template source. Default:schtask.xml.erb
.sensitive
- Suppress logging sensitive information. Default:true
.
This cookbook includes custom ChefSpec matchers you can use to test your own cookbooks.
Example Matcher Usage
expect(chef_run).to enable_windows_logrotate('resource_name')
Cookbook Matchers
- enable_windows_logrotate(resource_name)
- Ask specific questions on Stack Overflow.
- Report bugs and discuss potential features in Github issues.
Please refer to CONTRIBUTING.
MIT - see the accompanying LICENSE file for details.