Add Panko expirer class
This sets up a cron task to run periodically and expire panko events in db. Change-Id: I23359239008105cd77a599d2c08c067f132099b7 Partial-Bug: #1746514
This commit is contained in:
parent
ae02d117bb
commit
54de0d59e5
|
@ -0,0 +1,60 @@
|
||||||
|
#
|
||||||
|
# == Class: panko::expirer
|
||||||
|
#
|
||||||
|
# Setups Panko Expirer service to enable TTL feature.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*enable_cron*]
|
||||||
|
# (optional) Whether to configure a crontab entry to run the expiry.
|
||||||
|
# When set to False, Puppet will try to remove the crontab.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
|
# [*minute*]
|
||||||
|
# (optional) Defaults to '1'.
|
||||||
|
#
|
||||||
|
# [*hour*]
|
||||||
|
# (optional) Defaults to '0'.
|
||||||
|
#
|
||||||
|
# [*monthday*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
# [*month*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
# [*weekday*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
class panko::expirer (
|
||||||
|
$enable_cron = true,
|
||||||
|
$minute = 1,
|
||||||
|
$hour = 0,
|
||||||
|
$monthday = '*',
|
||||||
|
$month = '*',
|
||||||
|
$weekday = '*',
|
||||||
|
) {
|
||||||
|
|
||||||
|
include ::panko::params
|
||||||
|
include ::panko::deps
|
||||||
|
|
||||||
|
Anchor['panko::install::end'] ~> Class['panko::expirer']
|
||||||
|
|
||||||
|
if $enable_cron {
|
||||||
|
$ensure = 'present'
|
||||||
|
} else {
|
||||||
|
$ensure = 'absent'
|
||||||
|
}
|
||||||
|
|
||||||
|
cron { 'panko-expirer':
|
||||||
|
ensure => $ensure,
|
||||||
|
command => $panko::params::expirer_command,
|
||||||
|
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
|
user => 'panko',
|
||||||
|
minute => $minute,
|
||||||
|
hour => $hour,
|
||||||
|
monthday => $monthday,
|
||||||
|
month => $month,
|
||||||
|
weekday => $weekday
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ class panko::params {
|
||||||
include ::openstacklib::defaults
|
include ::openstacklib::defaults
|
||||||
$client_package_name = 'python-pankoclient'
|
$client_package_name = 'python-pankoclient'
|
||||||
$group = 'panko'
|
$group = 'panko'
|
||||||
|
$expirer_command = 'panko-expirer'
|
||||||
|
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Add panko expirer class so we can configure it in crontab accordingly.
|
|
@ -0,0 +1,53 @@
|
||||||
|
#
|
||||||
|
# Unit tests for panko::expirer
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'panko::expirer' do
|
||||||
|
|
||||||
|
shared_examples_for 'panko-expirer' do
|
||||||
|
|
||||||
|
it { is_expected.to contain_class('panko::deps') }
|
||||||
|
it { is_expected.to contain_class('panko::params') }
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures a cron' do
|
||||||
|
is_expected.to contain_cron('panko-expirer').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:command => 'panko-expirer',
|
||||||
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
|
:user => 'panko',
|
||||||
|
:minute => 1,
|
||||||
|
:hour => 0,
|
||||||
|
:monthday => '*',
|
||||||
|
:month => '*',
|
||||||
|
:weekday => '*'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with cron not enabled' do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:enable_cron => false })
|
||||||
|
end
|
||||||
|
it {
|
||||||
|
is_expected.to contain_cron('panko-expirer').with(
|
||||||
|
:ensure => 'absent',
|
||||||
|
:command => 'panko-expirer',
|
||||||
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
|
||||||
|
:user => 'panko',
|
||||||
|
:minute => 1,
|
||||||
|
:hour => 0,
|
||||||
|
:monthday => '*',
|
||||||
|
:month => '*',
|
||||||
|
:weekday => '*'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue