voxpupuli/puppet-logrotate

Add support for systemd-timer

Closed this issue · 0 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.26.0
  • Ruby: 2.7.0p0
  • Distribution: Ubuntu 20.04+, Debian 11+
  • Module version: v7.0.0

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

  • Module manages systemd-timer unit or
  • systemd-timer gets disabled

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',
}