Showing with 158 additions and 54 deletions.
  1. +1 −0 .fixtures.yml
  2. +7 −2 .github/workflows/ci.yml
  3. +1 −1 .github/workflows/release.yml
  4. +1 −1 .msync.yml
  5. +1 −0 .pmtignore
  6. +9 −0 CHANGELOG.md
  7. +3 −5 Gemfile
  8. +64 −6 manifests/hourly.pp
  9. +5 −1 metadata.json
  10. +66 −38 spec/classes/init_spec.rb
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
cron: "https://github.com/puppetlabs/puppetlabs-cron_core.git"
systemd: "https://github.com/voxpupuli/puppet-systemd.git"
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

name: CI

on: pull_request
on:
pull_request: {}
push:
branches:
- main
- master

concurrency:
group: ${{ github.ref_name }}
Expand All @@ -13,6 +18,6 @@ concurrency:
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
with:
pidfile_workaround: 'false'
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2
with:
allowed_owner: 'voxpupuli'
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '7.0.0'
modulesync_config_version: '7.3.0'
1 change: 1 addition & 0 deletions .pmtignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
/.yardoc/
/.yardopts
/Dockerfile
/HISTORY.md
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v7.0.2](https://github.com/voxpupuli/puppet-logrotate/tree/v7.0.2) (2024-02-28)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v7.0.1...v7.0.2)

**Fixed bugs:**

- Support hourly logrotate directory on EL9 again. [\#221](https://github.com/voxpupuli/puppet-logrotate/pull/221) ([traylenator](https://github.com/traylenator))
- Remove the managed hourly directory if the class is disabled [\#192](https://github.com/voxpupuli/puppet-logrotate/pull/192) ([flynet70](https://github.com/flynet70))

## [v7.0.1](https://github.com/voxpupuli/puppet-logrotate/tree/v7.0.1) (2023-12-05)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v7.0.0...v7.0.1)
Expand Down
8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group :test do
gem 'voxpupuli-test', '~> 7.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 3.0', :require => false
gem 'puppet_metadata', '~> 3.5', :require => false
end

group :development do
Expand All @@ -16,13 +16,11 @@ group :development do
end

group :system_tests do
gem 'voxpupuli-acceptance', '~> 2.0', :require => false
gem 'voxpupuli-acceptance', '~> 3.0', :require => false
end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false
gem 'voxpupuli-release', '~> 3.0', :require => false
gem 'faraday-retry', '~> 2.1', :require => false
gem 'voxpupuli-release', '~> 3.0', :require => false
end

gem 'rake', :require => false
Expand Down
70 changes: 64 additions & 6 deletions manifests/hourly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@
) {
assert_private()

$dir_ensure = $logrotate::ensure_cron_hourly ? {
'absent' => $logrotate::ensure_cron_hourly,
'present' => 'directory'
}

file { "${logrotate::rules_configdir}/hourly":
ensure => $dir_ensure,
ensure => 'directory',
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => $logrotate::rules_configdir_mode,
force => true,
}

if $logrotate::manage_cron_hourly {
Expand All @@ -37,4 +33,66 @@
require => File["${logrotate::rules_configdir}/hourly"],
}
}

# Make copies of the rpm provided unit and timers
if $logrotate::manage_systemd_timer {
$_lockfile = '/run/lock/logrotate.service'
$_timeout = 21600
systemd::manage_dropin { 'hourly-service.conf':
ensure => $logrotate::ensure_systemd_timer,
unit => 'logrotate-hourly.service',
unit_entry => {
'Description' => [
'',
'Extra service to run hourly logrotates only',
],
},
service_entry => {
'ExecStart' => ['', "/usr/bin/flock --wait ${_timeout} ${_lockfile} /usr/sbin/logrotate ${logrotate::rules_configdir}/hourly"],
},
before => Systemd::Unit_file['logrotate-hourly.service'],
}

# Once logrotate >= 3.21.1 replace flock with the `--wait-for-state-lock` option.
systemd::manage_dropin { 'logrotate-flock.conf':
ensure => $logrotate::ensure_systemd_timer,
unit => 'logrotate.service',
service_entry => {
'ExecStart' => ['', "/usr/bin/flock --wait ${_timeout} ${_lockfile} /usr/sbin/logrotate /etc/logrotate.conf"],
},
}

systemd::unit_file { 'logrotate-hourly.service':
ensure => $logrotate::ensure_systemd_timer,
source => 'file:///lib/systemd/system/logrotate.service',
before => Systemd::Unit_file['logrotate-hourly.timer'],
}

systemd::manage_dropin { 'hourly-timer.conf':
ensure => $logrotate::ensure_systemd_timer,
unit => 'logrotate-hourly.timer',
unit_entry => {
'Description' => [
'',
'Extra timer to run hourly logrotates only',
],
},
timer_entry => {
'OnCalendar' => ['', 'hourly'],
},
before => Systemd::Unit_file['logrotate-hourly.timer'],
}

$_timer = $logrotate::ensure_systemd_timer ? {
'present' => true,
default => false,
}

systemd::unit_file { 'logrotate-hourly.timer':
ensure => $logrotate::ensure_systemd_timer,
source => 'file:///lib/systemd/system/logrotate.timer',
active => $_timer,
enable => $_timer,
}
}
}
6 changes: 5 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-logrotate",
"version": "7.0.1",
"version": "7.0.2",
"author": "Vox Pupuli",
"summary": "Manage logrotate",
"license": "MIT",
Expand All @@ -14,6 +14,10 @@
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.22.0 < 10.0.0"
},
{
"name": "puppet/systemd",
"version_requirement": ">= 6.3.0 < 7.0.0"
}
],
"requirements": [
Expand Down
104 changes: 66 additions & 38 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@
let(:facts) do
facts
end
let(:cron_ensure) do
if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i >= 9
'absent'
else
'present'
end
end
let(:hourly_dir_ensure) do
if cron_ensure == 'present'
'directory'
else
'absent'
end
end

context 'logrotate class without any parameters' do
it { is_expected.to compile.with_all_deps }
Expand Down Expand Up @@ -54,23 +40,6 @@
is_expected.to contain_class('logrotate::defaults')
end
else
it do
is_expected.to contain_file('/etc/logrotate.d/hourly').with(
'ensure' => hourly_dir_ensure,
'owner' => 'root',
'group' => 'root',
'mode' => '0755'
)
end

it do
is_expected.to contain_file('/etc/cron.hourly/logrotate').with(
'ensure' => cron_ensure,
'owner' => 'root',
'group' => 'root',
'mode' => '0700'
)
end

it do
is_expected.to contain_package('logrotate').with_ensure('present')
Expand All @@ -80,11 +49,6 @@
'group' => 'root',
'mode' => '0755')

is_expected.to contain_file('/etc/cron.daily/logrotate').with('ensure' => cron_ensure,
'owner' => 'root',
'group' => 'root',
'mode' => '0700')

is_expected.to contain_class('logrotate::defaults')
end

Expand All @@ -94,10 +58,74 @@
'ensure' => 'running',
'enable' => true
)

is_expected.to contain_systemd__unit_file('logrotate-hourly.timer').with(
'ensure' => 'present',
'enable' => true,
'active' => true
)

is_expected.to contain_systemd__manage_dropin('hourly-timer.conf').with(
'ensure' => 'present',
'unit' => 'logrotate-hourly.timer'
)

is_expected.to contain_systemd__unit_file('logrotate-hourly.service').with_ensure('present').without_enable.without_active

is_expected.to contain_systemd__manage_dropin('hourly-service.conf').with(
'ensure' => 'present',
'unit' => 'logrotate-hourly.service',
'service_entry' => {
'ExecStart' => [
'',
'/usr/bin/flock --wait 21600 /run/lock/logrotate.service /usr/sbin/logrotate /etc/logrotate.d/hourly'
]
}
)

is_expected.to contain_systemd__manage_dropin('logrotate-flock.conf').with(
'ensure' => 'present',
'unit' => 'logrotate.service',
'service_entry' => {
'ExecStart' => [
'',
'/usr/bin/flock --wait 21600 /run/lock/logrotate.service /usr/sbin/logrotate /etc/logrotate.conf'
]
}
)
end
else

it do
is_expected.to contain_file('/etc/cron.hourly/logrotate').with(
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0700'
)

is_expected.to contain_file('/etc/cron.daily/logrotate').with('ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0700')
end

it do
is_expected.to contain_file('/etc/logrotate.d/hourly').with(
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0755'
)
end

it do
is_expected.not_to contain_service('logrotate.timer')
is_expected.not_to contain_systemd__unit_file('logrotate-hourly.timer')
is_expected.not_to contain_systemd__unit_file('logrotate-hourly.service')
is_expected.not_to contain_systemd__unit_file('logrotate-hourly.timer')
is_expected.not_to contain_systemd__unit_file('logrotate-hourly.service')
is_expected.not_to contain_systemd__manage_dropin('logrotate-flock.conf')
end
end
end
Expand Down Expand Up @@ -169,9 +197,9 @@

case facts[:operatingsystem]
when 'FreeBSD'
it { is_expected.to contain_file('/usr/local/etc/logrotate.d/hourly').with_ensure('absent') }
it { is_expected.to contain_file('/usr/local/etc/logrotate.d/hourly').with_ensure('directory') }
else
it { is_expected.to contain_file('/etc/logrotate.d/hourly').with_ensure('absent') }
it { is_expected.to contain_file('/etc/logrotate.d/hourly').with_ensure('directory') }
it { is_expected.to contain_file('/etc/cron.hourly/logrotate').with_ensure('absent') }
end
end
Expand Down