Skip to content
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
2 changes: 2 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ fixtures:
repo: puppet/systemd
php:
repo: puppet/php
systemd:
repo: puppet/systemd
symlinks:
xdmod: "#{source_dir}"
26 changes: 15 additions & 11 deletions manifests/cron.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@
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',
group => 'root',
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',
} + $xdmod::cron_service_overrides,
timer_overrides => $xdmod::cron_timer_overrides,
}

# Remove previous cron jobs
Expand Down
8 changes: 7 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@
# 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
# Manage XDMOD cron files and systemd timer
# @param manage_supremm_cron
# Manage SUPREMM cron files
# @param manage_akrr_cron
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
{
"name": "puppet/php",
"version_requirement": ">= 8.0.0 <13.0.0"
},
{
"name": "puppet/systemd",
"version_requirement": ">= 7.0.0 <9.0.0"
}
],
"operatingsystem_support": [
Expand Down
18 changes: 11 additions & 7 deletions spec/shared_examples/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down
1 change: 1 addition & 0 deletions templates/xdmod_cron.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# This file is managed by Puppet, do not edit!

<% if scope['xdmod::web'] -%>
Expand Down
Loading