Skip to content

Commit 18fe52a

Browse files
committed
Update and fix documentation
Signed-off-by: Dan Webb <[email protected]>
1 parent 6437442 commit 18fe52a

File tree

7 files changed

+102
-49
lines changed

7 files changed

+102
-49
lines changed

.github/workflows/ci.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,23 @@ jobs:
2323
strategy:
2424
matrix:
2525
os:
26-
- "almalinux-8"
27-
- "amazonlinux-2"
28-
- "centos-7"
29-
- "centos-stream-8"
30-
- "debian-10"
26+
- "almalinux-9"
27+
- "amazonlinux-2023"
28+
- "centos-stream-9"
29+
- "centos-stream-10"
3130
- "debian-11"
31+
- "debian-12"
3232
- "fedora-latest"
3333
- "opensuse-leap-15"
34-
- "rockylinux-8"
35-
- "ubuntu-1804"
3634
- "ubuntu-2004"
35+
- "ubuntu-2204"
3736
suite:
3837
- "default"
3938
fail-fast: false
4039

4140
steps:
4241
- name: Check out code
43-
uses: actions/checkout@v4 # v4
42+
uses: actions/checkout@v4
4443
- name: Install Chef
4544
uses: actionshub/[email protected]
4645
- name: Dokken

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
- cookstyle

README.md

+38-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
77
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
88

9-
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/.
1010

1111
## Maintainers
1212

@@ -27,49 +27,68 @@ Tested on:
2727

2828
### Chef
2929

30-
- Chef 12.5+
30+
- Chef 15.3+
3131

3232
## Resources
3333

34-
- [logrotate_app](documentation/logrotate_app.md)
35-
- [logrotate_global](documentation/logrotate_global.md)
36-
- [logrotate_package](documentation/logrotate_package.md)
34+
- [logrotate_app](documentation/logrotate_app.md) - Manages application-specific logrotate configurations
35+
- [logrotate_global](documentation/logrotate_global.md) - Manages the global logrotate configuration
36+
- [logrotate_package](documentation/logrotate_package.md) - Manages the logrotate package installation
3737

3838
## Usage
3939

40-
The package resource will ensure logrotate is always up to date by default.
40+
### Package Installation
4141

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:
4343

4444
```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+
)
5067
end
5168
```
5269

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:
5473

5574
```ruby
5675
logrotate_app 'tomcat-myapp' do
57-
path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out']
76+
path '/var/log/tomcat/myapp.log'
5877
frequency 'daily'
78+
rotate 30
5979
create '644 root adm'
60-
rotate 7
80+
options %w(missingok compress delaycompress copytruncate notifempty)
6181
end
6282
```
6383

64-
To specify which logrotate options, specify the options as an array:
84+
For multiple log files:
6585

6686
```ruby
6787
logrotate_app 'tomcat-myapp' do
68-
path '/var/log/tomcat/myapp.log'
69-
options ['missingok', 'delaycompress', 'notifempty']
88+
path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out']
7089
frequency 'daily'
71-
rotate 30
7290
create '644 root adm'
91+
rotate 7
7392
end
7493
```
7594

documentation/logrotate_app.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ The resource takes the following properties:
1111
| Name | Type | Default | Description |
1212
| ---------------- | ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
1313
| `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 |
2126

2227
## Examples
2328

documentation/logrotate_global.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22

33
[Back to resource list](../README.md#resources)
44

5-
This resource can be used to drop off customized logrotate config files on a per application basis.
5+
This resource can be used to manage the global logrotate configuration file.
66

77
The resource takes the following properties:
88

99
## Properties
1010

1111
| Name | Type | Default | Description |
1212
| ---------------- | ------------- | ----------------------- | --------------------------------------------------------------- |
13-
| `config_file` | String, | `'/etc/logrotate.conf'` | Specifies the path to the logrotate global config file. |
13+
| `config_file` | String | `'/etc/logrotate.conf'` | Specifies the path to the logrotate global config file. |
1414
| `template_name` | String | `logrotate-global.erb` | Sets the template source. |
15-
| `template_mode` | String | `logrotate` | The mode to create the logrotate config file template. |
16-
| `template_owner` | String | `logrotate` | The owner of the logrotate config file template. |
17-
| `template_group` | String | `logrotate` | The group of the logrotate config file template. |
18-
| `options` | String, Array | `['weekly', 'datext']` | Logrotate global options. |
15+
| `template_mode` | String | `0644` | The mode to create the logrotate config file template. |
16+
| `template_owner` | String | `root` | The owner of the logrotate config file template. |
17+
| `template_group` | String | `node['root_group']` | The group of the logrotate config file template. |
18+
| `cookbook` | String | `logrotate` | The cookbook that contains the template source. |
19+
| `options` | String, Array | `%w(weekly dateext)` | Logrotate global options. |
1920
| `includes` | String, Array | `[]` | Files or directories to include in the logrotate configuration. |
20-
| `parameters` | Hash | `{}` | Logrotate global parameters. |
21-
| `path` | Hash | `{}` | Logrotate global path definitions. |
22-
| `scripts` | Hash | `{}` | Logrotate global options. |
21+
| `parameters` | Hash | `{ 'rotate' => 4, 'create' => nil }` | Logrotate global parameters. |
22+
| `paths` | Hash | `{}` | Logrotate global path definitions. |
23+
| `scripts` | Hash | `{}` | Global scripts to run (firstaction, prerotate, postrotate, lastaction). |
2324

2425
## Examples
2526

documentation/logrotate_package.md

+32-5
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,57 @@
22

33
[Back to resource list](../README.md#resources)
44

5-
Install logrotate from package.
5+
Manages the installation of the logrotate package. This resource allows you to install, upgrade, or remove the logrotate package and its dependencies.
66

77
Introduced: v3.0.0
88

99
## Actions
1010

11-
- `:install`
12-
- `:upgrade`
13-
- `:remove`
11+
- `:upgrade` - Upgrade the logrotate package if a newer version is available
12+
- `:install` - Install the logrotate package (default)
13+
- `:remove` - Remove the logrotate package
1414

1515
## Properties
1616

1717
| Name | Type | Default | Description |
1818
| ---------- | ------------- | ------------- | ----------------------------------------- |
19-
| `packages` | String, Array | `'logrotate'` | List of packages to install for logrotate |
19+
| `packages` | String, Array | `'logrotate'` | Package name or array of package names to manage |
2020

2121
## Examples
2222

23+
Basic installation using defaults:
24+
2325
```ruby
2426
logrotate_package 'logrotate'
2527
```
2628

29+
Install a specific package:
30+
2731
```ruby
2832
logrotate_package 'logrotate' do
2933
packages 'logrotate-special-package'
3034
end
3135
```
36+
37+
Install multiple packages:
38+
39+
```ruby
40+
logrotate_package 'logrotate' do
41+
packages ['logrotate', 'logrotate-dbg']
42+
end
43+
```
44+
45+
Upgrade existing installation:
46+
47+
```ruby
48+
logrotate_package 'logrotate' do
49+
action :upgrade
50+
end
51+
```
52+
53+
Remove logrotate:
54+
55+
```ruby
56+
logrotate_package 'logrotate' do
57+
action :remove
58+
end

resources/global.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
default: 'root'
2929

3030
property :template_group, String,
31-
default: 'root'
31+
default: lazy { node['root_group'] }
3232

3333
property :template_mode, String,
3434
default: '0644'

0 commit comments

Comments
 (0)