Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and fix documentation #200

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,30 @@ jobs:
strategy:
matrix:
os:
- "almalinux-8"
- "amazonlinux-2"
- "centos-7"
- "centos-stream-8"
- "debian-10"
- "almalinux-9"
- "amazonlinux-2023"
- "centos-stream-9"
- "centos-stream-10"
- "debian-11"
- "fedora-latest"
- "opensuse-leap-15"
- "rockylinux-8"
- "ubuntu-1804"
- "ubuntu-2004"
- "debian-12"
# - "opensuse-leap-15"
- "ubuntu-2204"
- "ubuntu-2404"
suite:
- "default"
fail-fast: false

steps:
- name: Check out code
uses: actions/checkout@v4 # v4
uses: actions/checkout@v4
- name: Install Chef
uses: actionshub/[email protected]
- name: Dokken
uses: actionshub/[email protected]
env:
CHEF_LICENSE: accept-no-persist
KITCHEN_LOCAL_YAML: kitchen.dokken.yml
CHEF_VERSION: ${{ vars.CHEF_VERSION }}
with:
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require:
- cookstyle
89 changes: 48 additions & 41 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,54 @@ This file is used to list changes made in each version of the logrotate cookbook

Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management

## 3.0.26 - *2024-07-15*

Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management

## 3.0.25 - *2024-05-06*

No notable changes

## 3.0.24 - *2024-05-06*

No notable changes

## 3.0.23 - *2023-09-28*

No notable changes

## 3.0.22 - *2023-09-04*

No notable changes

## 3.0.21 - *2023-07-10*

No notable changes

## 3.0.20 - *2023-05-17*

No notable changes

## 3.0.19 - *2023-04-07*

Standardise files with files in sous-chefs/repo-management

## 3.0.18 - *2023-04-01*

No notable changes

## 3.0.17 - *2023-04-01*

## 3.0.16 - *2023-04-01*
No notable changes

Standardise files with files in sous-chefs/repo-management
## 3.0.16 - *2023-04-01*

Standardise files with files in sous-chefs/repo-management

## 3.0.15 - *2023-03-02*

No notable changes

## 3.0.14 - *2023-02-27*

Standardise files with files in sous-chefs/repo-management
Expand All @@ -64,39 +74,37 @@ Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management

## 3.0.9 - *2022-02-17*

- Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management

## 3.0.8 - *2022-02-08*

- Remove delivery folder
Remove delivery folder

## 3.0.7 - *2022-02-01*

- Update tested platforms
Update tested platforms

## 3.0.6 - *2022-01-14*

- Do not sort options as the order can be important
Do not sort options as the order can be important

## 3.0.5 - *2021-11-03*

- Add CentOS Stream 8 to CI pipeline
Add CentOS Stream 8 to CI pipeline

## 3.0.4 - *2021-08-30*

- Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management

## 3.0.3 - *2021-06-01*

- Standardise files with files in sous-chefs/repo-management
Standardise files with files in sous-chefs/repo-management

## 3.0.2 - *2021-05-12*

- Fix passing options to global path declarations
Fix passing options to global path declarations

## 3.0.1 - *2021-05-12*

Expand Down Expand Up @@ -218,46 +226,45 @@ Standardise files with files in sous-chefs/repo-management
- 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.
- Allow to use maxsize parameter.
- Allow to use dateyesterday option.
- Allow to use su parameter.
- Allows use of the dateformat parameter.
- Loosen test-kitchen version constraint
- Add rvm files to gitignore

## 1.4.0

- **[COOK-3632](https://tickets.chef.io/browse/COOK-3632)** - Raise Exception when adding more than one invalid option
- **[COOK-3141](https://tickets.chef.io/browse/COOK-3141)** - Do not duplicate template entires for multiple paths
- **[COOK-3034](https://tickets.chef.io/browse/COOK-3034)** - Update logrotate_app params to accept arrays and strings
- **[COOK-2646](https://tickets.chef.io/browse/COOK-2646)** - Add ability to choose file mode for logrotate template
- Raise Exception when adding more than one invalid option
- Do not duplicate template entires for multiple paths
- Update logrotate_app params to accept arrays and strings
- Add ability to choose file mode for logrotate template

## 1.3.0

- **[COOK-3341](https://tickets.chef.io/browse/COOK-3341)** - Add optional `frequency` and `rotate` params when defined globally
- **[COOK-3298](https://tickets.chef.io/browse/COOK-3298)** - Use `Array` instead of `respond_to?(:each)`
- **[COOK-3285](https://tickets.chef.io/browse/COOK-3285)** - Change `logrotate.d` config file mode to `0644`
- **[COOK-3250](https://tickets.chef.io/browse/COOK-3250)** - Add `minsize`
- **[COOK-3274](https://tickets.chef.io/browse/COOK-3274)** - Fix README typo that suggested the opposite action

- **[COOK-2923](https://tickets.chef.io/browse/COOK-2923)** - Add `olddir` option
- **[COOK-1651](https://tickets.chef.io/browse/COOK-1651)** - Add `dateext` ability
- Add optional `frequency` and `rotate` params when defined globally
- Use `Array` instead of `respond_to?(:each)`
- Change `logrotate.d` config file mode to `0644`
- Add `minsize`
- Fix README typo that suggested the opposite action
- Add `olddir` option
- Add `dateext` ability

## 1.2.2

- [COOK-2872]: Add firstaction/lastaction ability to logrotate
- [COOK-2908]: Argument error in `logrotate_app` definition
- Add firstaction/lastaction ability to logrotate
- Argument error in `logrotate_app` definition

## 1.2.0

- [COOK-2401] - Add the ability to manage the global logrotate configuration
- Add the ability to manage the global logrotate configuration

## 1.1.0

- [COOK-2218] - Logrotate size parameter
- 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
- Add support for pre-/post-rotate commands
- Update log rotate for more flexibility of rotate options
- "Create" isn't a mandatory option
57 changes: 38 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)

Manages the logrotate package and provides a resource to manage application specific logrotate configuration.
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/.

## Maintainers

Expand All @@ -27,49 +27,68 @@ Tested on:

### Chef

- Chef 12.5+
- Chef 15.3+

## Resources

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

## Usage

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

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`:
By default, the cookbook will install the logrotate package:

```ruby
logrotate_app 'tomcat-myapp' do
path '/var/log/tomcat/myapp.log'
frequency 'daily'
rotate 30
create '644 root adm'
logrotate_package 'logrotate'
```

### Global Configuration

To manage the global logrotate configuration:

```ruby
logrotate_global 'logrotate' do
options %w(weekly dateext)
parameters(
'rotate' => 4,
'create' => nil
)
paths(
'/var/log/wtmp' => {
'missingok' => true,
'monthly' => true,
'create' => '0664 root utmp',
'rotate' => 1
}
)
end
```

To rotate multiple logfile paths, specify the path as an array:
### Application-Specific Configuration

To create application-specific logrotate configs, use the `logrotate_app` resource:

```ruby
logrotate_app 'tomcat-myapp' do
path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out']
path '/var/log/tomcat/myapp.log'
frequency 'daily'
rotate 30
create '644 root adm'
rotate 7
options %w(missingok compress delaycompress copytruncate notifempty)
end
```

To specify which logrotate options, specify the options as an array:
For multiple log files:

```ruby
logrotate_app 'tomcat-myapp' do
path '/var/log/tomcat/myapp.log'
options ['missingok', 'delaycompress', 'notifempty']
path ['/var/log/tomcat/myapp.log', '/opt/local/tomcat/catalina.out']
frequency 'daily'
rotate 30
create '644 root adm'
rotate 7
end
```

Expand Down
19 changes: 12 additions & 7 deletions documentation/logrotate_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ The resource takes the following properties:
| Name | Type | Default | Description |
| ---------------- | ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `path` | String, Array | `nil` | Specifies a single path (string) or multiple paths (array) that should have logrotation stanzas created in the config file. |
| `cookbook` | String | `logrotate` | The cookbook that continues the template for logrotate_app config resources. |
| `template_name` | String | `logrotate` | Sets the template source. |
| `template_mode` | String | `logrotate` | The mode to create the logrotate template. |
| `template_owner` | String | `logrotate` | The owner of the logrotate template. |
| `template_group` | String | `logrotate` | The group of the logrotate template. |
| `frequency` | String | `logrotate` | Sets the frequency for rotation. Valid values are: hourly, daily, weekly, monthly, yearly, see the logrotate man page for more information. |
| `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. |
| `cookbook` | String | `node['root_group']` | The cookbook that continues the template for logrotate_app config resources. |
| `template_name` | String | `logrotate.erb` | Sets the template source. |
| `template_mode` | String | `0644` | The mode to create the logrotate template. |
| `template_owner` | String | `root` | The owner of the logrotate template. |
| `template_group` | String | `root` | The group of the logrotate template. |
| `frequency` | String | `weekly` | Sets the frequency for rotation. Valid values are: hourly, daily, weekly, monthly, yearly, see the logrotate man page for more information. |
| `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. |
| `base_dir` | String | `/etc/logrotate.d` | The base directory where the logrotate configuration files will be stored. |
| `firstaction` | String, Array | `nil` | Script to run before log files are rotated |
| `prerotate` | String, Array | `nil` | Script to run before individual log file is rotated |
| `postrotate` | String, Array | `nil` | Script to run after individual log file is rotated |
| `lastaction` | String, Array | `nil` | Script to run after all log files are rotated |

## Examples

Expand Down
19 changes: 10 additions & 9 deletions documentation/logrotate_global.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

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

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

The resource takes the following properties:

## Properties

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

## Examples

Expand Down
Loading
Loading