Merge "Allow disabling or delaying the token_flush cron"
This commit is contained in:
commit
0df9701dcf
|
@ -21,6 +21,10 @@
|
||||||
#
|
#
|
||||||
# === Parameters
|
# === Parameters
|
||||||
#
|
#
|
||||||
|
# [*ensure*]
|
||||||
|
# (optional) Defaults to present.
|
||||||
|
# Valid values are present, absent.
|
||||||
|
#
|
||||||
# [*minute*]
|
# [*minute*]
|
||||||
# (optional) Defaults to '1'.
|
# (optional) Defaults to '1'.
|
||||||
#
|
#
|
||||||
|
@ -36,16 +40,30 @@
|
||||||
# [*weekday*]
|
# [*weekday*]
|
||||||
# (optional) Defaults to '*'.
|
# (optional) Defaults to '*'.
|
||||||
#
|
#
|
||||||
|
# [*maxdelay*]
|
||||||
|
# (optional) Seconds. Defaults to 0. Should be a positive integer.
|
||||||
|
# Induces a random delay before running the cronjob to avoid running all
|
||||||
|
# cron jobs at the same time on all hosts this job is configured.
|
||||||
|
#
|
||||||
class keystone::cron::token_flush (
|
class keystone::cron::token_flush (
|
||||||
|
$ensure = present,
|
||||||
$minute = 1,
|
$minute = 1,
|
||||||
$hour = 0,
|
$hour = 0,
|
||||||
$monthday = '*',
|
$monthday = '*',
|
||||||
$month = '*',
|
$month = '*',
|
||||||
$weekday = '*',
|
$weekday = '*',
|
||||||
|
$maxdelay = 0,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
if $maxdelay == 0 {
|
||||||
|
$sleep = ''
|
||||||
|
} else {
|
||||||
|
$sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; "
|
||||||
|
}
|
||||||
|
|
||||||
cron { 'keystone-manage token_flush':
|
cron { 'keystone-manage token_flush':
|
||||||
command => 'keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1',
|
ensure => $ensure,
|
||||||
|
command => "${sleep}keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1",
|
||||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
user => 'keystone',
|
user => 'keystone',
|
||||||
minute => $minute,
|
minute => $minute,
|
||||||
|
|
|
@ -6,8 +6,10 @@ describe 'keystone::cron::token_flush' do
|
||||||
{ :osfamily => 'Debian' }
|
{ :osfamily => 'Debian' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'with default parameters' do
|
||||||
it 'configures a cron' do
|
it 'configures a cron' do
|
||||||
should contain_cron('keystone-manage token_flush').with(
|
should contain_cron('keystone-manage token_flush').with(
|
||||||
|
:ensure => 'present',
|
||||||
:command => 'keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1',
|
:command => 'keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1',
|
||||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
:user => 'keystone',
|
:user => 'keystone',
|
||||||
|
@ -19,3 +21,48 @@ describe 'keystone::cron::token_flush' do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when specifying a maxdelay param' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:maxdelay => 600
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures a cron with delay' do
|
||||||
|
should contain_cron('keystone-manage token_flush').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:command => 'sleep `expr ${RANDOM} \\% 600`; keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1',
|
||||||
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
|
:user => 'keystone',
|
||||||
|
:minute => 1,
|
||||||
|
:hour => 0,
|
||||||
|
:monthday => '*',
|
||||||
|
:month => '*',
|
||||||
|
:weekday => '*'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when specifying a maxdelay param' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:ensure => 'absent'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures a cron with delay' do
|
||||||
|
should contain_cron('keystone-manage token_flush').with(
|
||||||
|
:ensure => 'absent',
|
||||||
|
:command => 'keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1',
|
||||||
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
|
:user => 'keystone',
|
||||||
|
:minute => 1,
|
||||||
|
:hour => 0,
|
||||||
|
:monthday => '*',
|
||||||
|
:month => '*',
|
||||||
|
:weekday => '*'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue