Allow customizing --date option for trust_flush cron job
This change introduces the new age parameter so that --date options is enabled when running the trust_flush cron job. Change-Id: I7d4a5a08c73683fff8fd270e5bc991531f8dda48
This commit is contained in:
parent
ae0b8a6772
commit
7465a117bd
manifests/cron
releasenotes/notes
spec/classes
@ -48,6 +48,10 @@
|
||||
# cron jobs at the same time on all hosts this job is configured.
|
||||
# Defaults to 0
|
||||
#
|
||||
# [*age*]
|
||||
# (Optional) Number of days prior to today for deletion,
|
||||
# Defaults to 0
|
||||
#
|
||||
# [*destination*]
|
||||
# (Optional) Path to file to which rows should be archived
|
||||
# Defaults to '/var/log/keystone/keystone-trustflush.log'
|
||||
@ -64,6 +68,7 @@ class keystone::cron::trust_flush (
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
Integer $maxdelay = 0,
|
||||
Integer $age = 0,
|
||||
$destination = '/var/log/keystone/keystone-trustflush.log',
|
||||
$user = $::keystone::params::user,
|
||||
) inherits keystone::params {
|
||||
@ -76,9 +81,15 @@ class keystone::cron::trust_flush (
|
||||
$sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; "
|
||||
}
|
||||
|
||||
if $age == 0 {
|
||||
$date = ''
|
||||
} else {
|
||||
$date = "--date `date --date 'today - ${age} days' +\\%d-\\%m-\\%Y` "
|
||||
}
|
||||
|
||||
cron { 'keystone-manage trust_flush':
|
||||
ensure => $ensure,
|
||||
command => "${sleep}keystone-manage trust_flush >>${destination} 2>&1",
|
||||
command => "${sleep}keystone-manage trust_flush ${date}>>${destination} 2>&1",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
user => $user,
|
||||
minute => $minute,
|
||||
|
4
releasenotes/notes/token_flush-age-a4b11555aac09a2e.yaml
Normal file
4
releasenotes/notes/token_flush-age-a4b11555aac09a2e.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``keystone::cron::token_flush::age`` parameter has been added.
|
@ -25,15 +25,16 @@ describe 'keystone::cron::trust_flush' do
|
||||
|
||||
context 'with overriden params' do
|
||||
before do
|
||||
params.merge!( :ensure => 'absent',
|
||||
:minute => 13,
|
||||
:hour => 23,
|
||||
:monthday => 3,
|
||||
:month => 4,
|
||||
:weekday => 2,
|
||||
:maxdelay => 600,
|
||||
:destination => '/tmp/trustflush.log',
|
||||
:user => 'nobody' )
|
||||
params.merge!(
|
||||
:ensure => 'absent',
|
||||
:minute => 13,
|
||||
:hour => 23,
|
||||
:monthday => 3,
|
||||
:month => 4,
|
||||
:weekday => 2,
|
||||
:maxdelay => 600,
|
||||
:destination => '/tmp/trustflush.log',
|
||||
:user => 'nobody' )
|
||||
end
|
||||
|
||||
it { is_expected.to contain_class('keystone::deps') }
|
||||
@ -51,6 +52,27 @@ describe 'keystone::cron::trust_flush' do
|
||||
:require => 'Anchor[keystone::dbsync::end]',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with age' do
|
||||
before do
|
||||
params.merge!(
|
||||
:age => 14
|
||||
)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_cron('keystone-manage trust_flush').with(
|
||||
:ensure => 'present',
|
||||
:command => 'keystone-manage trust_flush --date `date --date \'today - 14 days\' +\\%d-\\%m-\\%Y` >>/var/log/keystone/keystone-trustflush.log 2>&1',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||
:user => 'keystone',
|
||||
:minute => 1,
|
||||
:hour => '*',
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*',
|
||||
:require => 'Anchor[keystone::dbsync::end]',
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
Loading…
x
Reference in New Issue
Block a user