From f0147be89479d60db507f59c466058702d54d7b8 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Wed, 22 Apr 2026 14:30:04 -0400 Subject: [PATCH 1/5] Use a systemd timer instead of cron --- .fixtures.yml | 2 ++ manifests/cron.pp | 25 ++++++++++++++----------- manifests/init.pp | 2 +- metadata.json | 4 ++++ spec/shared_examples/cron.rb | 18 +++++++++++------- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 8517dc2..2d4f9e4 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -41,5 +41,7 @@ fixtures: repo: puppet/systemd php: repo: puppet/php + systemd: + repo: puppet/systemd symlinks: xdmod: "#{source_dir}" diff --git a/manifests/cron.pp b/manifests/cron.pp index b5a0a13..74090ba 100644 --- a/manifests/cron.pp +++ b/manifests/cron.pp @@ -5,8 +5,8 @@ assert_private() if $xdmod::manage_cron { - $minute = $xdmod::cron_times[0] - $hour = $xdmod::cron_times[1] + $minute = sprintf('%02d', $xdmod::cron_times[0]) + $hour = sprintf('%02d', $xdmod::cron_times[1]) file { '/usr/local/bin/xdmod-cron.sh': ensure => 'file', owner => 'root', @@ -14,16 +14,19 @@ mode => '0755', content => template('xdmod/xdmod_cron.erb'), } + # Remove packaged cron job file { '/etc/cron.d/xdmod': - ensure => 'file', - owner => 'root', - group => 'root', - mode => '0644', - content => join([ - '# File managed by Puppet, DO NOT EDIT', - "${minute} ${hour} * * * xdmod /usr/local/bin/xdmod-cron.sh", - '', - ], "\n"), + ensure => 'absent', + } + systemd::timer_wrapper { 'xdmod-cron': + ensure => 'present', + command => '/usr/local/bin/xdmod-cron.sh', + on_calendar => "*-*-* ${hour}:${minute}:00", + user => 'xdmod', + service_overrides => { + 'Group' => 'xdmod', + 'SyslogIdentifier' => 'xdmod-cron', + }, } # Remove previous cron jobs diff --git a/manifests/init.pp b/manifests/init.pp index c215ff8..a154135 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -249,7 +249,7 @@ # @param cron_times # The cron times for XDMOD cron jobs # @param manage_cron -# Manage XDMOD cron files +# Manage XDMOD cron files and systemd timer # @param manage_supremm_cron # Manage SUPREMM cron files # @param manage_akrr_cron diff --git a/metadata.json b/metadata.json index 5f8c977..9b8aaf7 100644 --- a/metadata.json +++ b/metadata.json @@ -63,6 +63,10 @@ { "name": "puppet/php", "version_requirement": ">= 8.0.0 <13.0.0" + }, + { + "name": "puppet/systemd", + "version_requirement": ">= 6.5.0 <10.0.0" } ], "operatingsystem_support": [ diff --git a/spec/shared_examples/cron.rb b/spec/shared_examples/cron.rb index 73d52e7..87bc71e 100644 --- a/spec/shared_examples/cron.rb +++ b/spec/shared_examples/cron.rb @@ -20,17 +20,21 @@ it do is_expected.to contain_file('/etc/cron.d/xdmod').with( - ensure: 'file', - owner: 'root', - group: 'root', - mode: '0644', + ensure: 'absent', ) end it do - verify_contents(catalogue, '/etc/cron.d/xdmod', [ - '1 0 * * * xdmod /usr/local/bin/xdmod-cron.sh', - ],) + is_expected.to contain_systemd__timer_wrapper('xdmod-cron').with( + ensure: 'present', + command: '/usr/local/bin/xdmod-cron.sh', + on_calendar: '*-*-* 00:01:00', + user: 'xdmod', + service_overrides: { + 'Group' => 'xdmod', + 'SyslogIdentifier' => 'xdmod-cron', + }, + ) end it { is_expected.to contain_file('/etc/cron.d/xdmod-storage').with_ensure('absent') } From dd6155b16a1d1b435a450004d70790a0f6ddaa4e Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Wed, 22 Apr 2026 14:55:49 -0400 Subject: [PATCH 2/5] Reduce max systemd to 9 for now to avoid conflicts with mongodb module --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 9b8aaf7..5147b30 100644 --- a/metadata.json +++ b/metadata.json @@ -66,7 +66,7 @@ }, { "name": "puppet/systemd", - "version_requirement": ">= 6.5.0 <10.0.0" + "version_requirement": ">= 6.5.0 <9.0.0" } ], "operatingsystem_support": [ From 2e9d67af3e34b7570c3c10f24022d0363e4ab75d Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Thu, 23 Apr 2026 11:19:13 -0400 Subject: [PATCH 3/5] Require at least 7.0.0 for systemd --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 5147b30..8c74ffb 100644 --- a/metadata.json +++ b/metadata.json @@ -66,7 +66,7 @@ }, { "name": "puppet/systemd", - "version_requirement": ">= 6.5.0 <9.0.0" + "version_requirement": ">= 7.0.0 <9.0.0" } ], "operatingsystem_support": [ From 2c87dbe031363230559af4c0dbcc91ec45c86725 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Fri, 24 Apr 2026 09:37:40 -0400 Subject: [PATCH 4/5] Add shebang to cron script --- templates/xdmod_cron.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/xdmod_cron.erb b/templates/xdmod_cron.erb index b206d98..0f7bc1a 100644 --- a/templates/xdmod_cron.erb +++ b/templates/xdmod_cron.erb @@ -1,3 +1,4 @@ +#!/bin/bash # This file is managed by Puppet, do not edit! <% if scope['xdmod::web'] -%> From 38496f75e96327ac1034af21d48a55098ba11278 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Mon, 27 Apr 2026 16:10:10 -0400 Subject: [PATCH 5/5] Add cron_service_overrides and cron_timer_overrides parameters --- manifests/cron.pp | 3 ++- manifests/init.pp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/cron.pp b/manifests/cron.pp index 74090ba..a9b5471 100644 --- a/manifests/cron.pp +++ b/manifests/cron.pp @@ -26,7 +26,8 @@ service_overrides => { 'Group' => 'xdmod', 'SyslogIdentifier' => 'xdmod-cron', - }, + } + $xdmod::cron_service_overrides, + timer_overrides => $xdmod::cron_timer_overrides, } # Remove previous cron jobs diff --git a/manifests/init.pp b/manifests/init.pp index a154135..5609345 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -248,6 +248,10 @@ # The source of storage roles.json # @param cron_times # The cron times for XDMOD cron jobs +# @param cron_service_overrides +# The cron service unit overrides +# @param cron_timer_overrides +# The cron timer unit overrides # @param manage_cron # Manage XDMOD cron files and systemd timer # @param manage_supremm_cron @@ -414,6 +418,8 @@ String $storage_roles_source = 'puppet:///modules/xdmod/roles.d/storage.json', Array[Integer, 2, 2] $cron_times = [1, 0], + Hash $cron_service_overrides = {}, + Optional[Hash] $cron_timer_overrides = undef, Boolean $manage_cron = true, Boolean $manage_supremm_cron = true, Boolean $manage_akrr_cron = true,