voxpupuli / puppet-logrotate

Puppet logrotate module
https://forge.puppet.com/puppet/logrotate
MIT License
26 stars 92 forks source link

Add support for systemd-timer #214

Closed vrandr closed 11 months ago

vrandr commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

class { '::logrotate':
  manage_cron_daily  => true,
  ensure_cron_daily  => 'present',
  manage_cron_hourly => true,
  ensure_cron_hourly => 'present',
}

What are you seeing

On Ubuntu 20.04+ and at least Debian 11+ the logrotate package ships a systemd-timer unit which takes presence over the configured cronjob.

$cron_daily_hour and $cron_daily_minute will be ignored.

What behaviour did you expect instead

Output log

$ uname -a
Linux host.fqdn 5.15.0-1044-aws #49~20.04.1-Ubuntu SMP Mon Aug 21 17:09:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ systemctl list-timers logrotate.timer
NEXT                         LEFT     LAST                         PASSED  UNIT            ACTIVATES
Wed 2023-09-20 00:00:00 CEST 13h left Tue 2023-09-19 00:00:01 CEST 10h ago logrotate.timer logrotate.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.

$ systemctl cat logrotate.timer
# /lib/systemd/system/logrotate.timer
[Unit]
Description=Daily rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)

[Timer]
OnCalendar=daily
AccuracySec=12h
Persistent=true

[Install]
WantedBy=timers.target

Any additional information you'd like to impart

Disabling the timer unit can be archived with:

systemd::timer { 'logrotate.timer':
  active => false,
  enable => 'mask',
}