You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manages the logrotate package and provides a resource to manage application specific logrotate configuration.
9
+
Manages the logrotate package and provides resources to manage both global and application-specific logrotate configurations. This cookbook allows you to manage the logrotate package installation and create configuration for both the main logrotate.conf file and application-specific configurations in /etc/logrotate.d/.
-[logrotate_global](documentation/logrotate_global.md) - Manages the global logrotate configuration
36
+
-[logrotate_package](documentation/logrotate_package.md) - Manages the logrotate package installation
37
37
38
38
## Usage
39
39
40
-
The package resource will ensure logrotate is always up to date by default.
40
+
### Package Installation
41
41
42
-
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`:
42
+
By default, the cookbook will install the logrotate package:
43
43
44
44
```ruby
45
-
logrotate_app 'tomcat-myapp'do
46
-
path '/var/log/tomcat/myapp.log'
47
-
frequency 'daily'
48
-
rotate 30
49
-
create '644 root adm'
45
+
logrotate_package 'logrotate'
46
+
```
47
+
48
+
### Global Configuration
49
+
50
+
To manage the global logrotate configuration:
51
+
52
+
```ruby
53
+
logrotate_global 'logrotate'do
54
+
options %w(weekly dateext)
55
+
parameters(
56
+
'rotate' => 4,
57
+
'create' => nil
58
+
)
59
+
paths(
60
+
'/var/log/wtmp' => {
61
+
'missingok' => true,
62
+
'monthly' => true,
63
+
'create' => '0664 root utmp',
64
+
'rotate' => 1
65
+
}
66
+
)
50
67
end
51
68
```
52
69
53
-
To rotate multiple logfile paths, specify the path as an array:
70
+
### Application-Specific Configuration
71
+
72
+
To create application-specific logrotate configs, use the `logrotate_app` resource:
|`path`| String, Array |`nil`| Specifies a single path (string) or multiple paths (array) that should have logrotation stanzas created in the config file. |
14
-
|`cookbook`| String |`logrotate`| The cookbook that continues the template for logrotate_app config resources. |
15
-
|`template_name`| String |`logrotate`| Sets the template source. |
16
-
|`template_mode`| String |`logrotate`| The mode to create the logrotate template. |
17
-
|`template_owner`| String |`logrotate`| The owner of the logrotate template. |
18
-
|`template_group`| String |`logrotate`| The group of the logrotate template. |
19
-
|`frequency`| String |`logrotate`| Sets the frequency for rotation. Valid values are: hourly, daily, weekly, monthly, yearly, see the logrotate man page for more information. |
20
-
|`options`| String |`logrotate`| Any logrotate configuration option that doesn't specify a value. See the logrotate(8) manual page of v3.9.2 or earlier for details. |
14
+
|`cookbook`| String |`node['root_group']`| The cookbook that continues the template for logrotate_app config resources. |
15
+
|`template_name`| String |`logrotate.erb`| Sets the template source. |
16
+
|`template_mode`| String |`0644`| The mode to create the logrotate template. |
17
+
|`template_owner`| String |`root`| The owner of the logrotate template. |
18
+
|`template_group`| String |`root`| The group of the logrotate template. |
19
+
|`frequency`| String |`weekly`| Sets the frequency for rotation. Valid values are: hourly, daily, weekly, monthly, yearly, see the logrotate man page for more information. |
20
+
|`options`| String, Array |`%w(missingok compress delaycompress copytruncate notifempty)`| Any logrotate configuration option that doesn't specify a value. See the logrotate(8) manual page of v3.9.2 or earlier for details. |
21
+
|`base_dir`| String |`/etc/logrotate.d`| The base directory where the logrotate configuration files will be stored. |
22
+
|`firstaction`| String, Array |`nil`| Script to run before log files are rotated |
23
+
|`prerotate`| String, Array |`nil`| Script to run before individual log file is rotated |
24
+
|`postrotate`| String, Array |`nil`| Script to run after individual log file is rotated |
25
+
|`lastaction`| String, Array |`nil`| Script to run after all log files are rotated |
0 commit comments