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
|
@ -48,6 +48,10 @@
|
||||||
# cron jobs at the same time on all hosts this job is configured.
|
# cron jobs at the same time on all hosts this job is configured.
|
||||||
# Defaults to 0
|
# Defaults to 0
|
||||||
#
|
#
|
||||||
|
# [*age*]
|
||||||
|
# (Optional) Number of days prior to today for deletion,
|
||||||
|
# Defaults to 0
|
||||||
|
#
|
||||||
# [*destination*]
|
# [*destination*]
|
||||||
# (Optional) Path to file to which rows should be archived
|
# (Optional) Path to file to which rows should be archived
|
||||||
# Defaults to '/var/log/keystone/keystone-trustflush.log'
|
# Defaults to '/var/log/keystone/keystone-trustflush.log'
|
||||||
|
@ -64,6 +68,7 @@ class keystone::cron::trust_flush (
|
||||||
$month = '*',
|
$month = '*',
|
||||||
$weekday = '*',
|
$weekday = '*',
|
||||||
Integer $maxdelay = 0,
|
Integer $maxdelay = 0,
|
||||||
|
Integer $age = 0,
|
||||||
$destination = '/var/log/keystone/keystone-trustflush.log',
|
$destination = '/var/log/keystone/keystone-trustflush.log',
|
||||||
$user = $::keystone::params::user,
|
$user = $::keystone::params::user,
|
||||||
) inherits keystone::params {
|
) inherits keystone::params {
|
||||||
|
@ -76,9 +81,15 @@ class keystone::cron::trust_flush (
|
||||||
$sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; "
|
$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':
|
cron { 'keystone-manage trust_flush':
|
||||||
ensure => $ensure,
|
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',
|
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
user => $user,
|
user => $user,
|
||||||
minute => $minute,
|
minute => $minute,
|
||||||
|
|
|
@ -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
|
context 'with overriden params' do
|
||||||
before do
|
before do
|
||||||
params.merge!( :ensure => 'absent',
|
params.merge!(
|
||||||
:minute => 13,
|
:ensure => 'absent',
|
||||||
:hour => 23,
|
:minute => 13,
|
||||||
:monthday => 3,
|
:hour => 23,
|
||||||
:month => 4,
|
:monthday => 3,
|
||||||
:weekday => 2,
|
:month => 4,
|
||||||
:maxdelay => 600,
|
:weekday => 2,
|
||||||
:destination => '/tmp/trustflush.log',
|
:maxdelay => 600,
|
||||||
:user => 'nobody' )
|
:destination => '/tmp/trustflush.log',
|
||||||
|
:user => 'nobody' )
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_class('keystone::deps') }
|
it { is_expected.to contain_class('keystone::deps') }
|
||||||
|
@ -51,6 +52,27 @@ describe 'keystone::cron::trust_flush' do
|
||||||
:require => 'Anchor[keystone::dbsync::end]',
|
:require => 'Anchor[keystone::dbsync::end]',
|
||||||
)}
|
)}
|
||||||
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
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
|
|
Loading…
Reference in New Issue