Manage aodh-expirer package by aodh::expirer class

Since aodh-expirer command is included in a different package, we need
to manage that package as well in the corresponding class.

Change-Id: Ie3111d5a168e8d15f3e04d410a5a5c30b44324c2
(cherry picked from commit 007d3a82f6)
This commit is contained in:
Takashi Kajinami 2020-10-03 23:02:38 +09:00
parent 127fba4608
commit fe6ca076f3
3 changed files with 44 additions and 7 deletions

View File

@ -9,6 +9,10 @@
# (optional) The state of cron job. # (optional) The state of cron job.
# Defaults to present. # Defaults to present.
# #
# [*package_ensure*]
# (optional) ensure state for package.
# Defaults to 'present'
#
# [*minute*] # [*minute*]
# (optional) Defaults to '1'. # (optional) Defaults to '1'.
# #
@ -31,18 +35,24 @@
# Defaults to 0. # Defaults to 0.
# #
class aodh::expirer ( class aodh::expirer (
$ensure = 'present', $ensure = 'present',
$minute = 1, $package_ensure = 'present',
$hour = 0, $minute = 1,
$monthday = '*', $hour = 0,
$month = '*', $monthday = '*',
$weekday = '*', $month = '*',
$maxdelay = 0, $weekday = '*',
$maxdelay = 0,
) { ) {
include aodh::params include aodh::params
include aodh::deps include aodh::deps
ensure_resource( 'package', [$::aodh::params::expirer_package_name],
{ ensure => $package_ensure,
tag => ['openstack', 'aodh-package'] }
)
if $maxdelay == 0 { if $maxdelay == 0 {
$sleep = '' $sleep = ''
} else { } else {

View File

@ -0,0 +1,5 @@
---
features:
- |
Now the ``aodh::expirer`` class installs aodh-expire package automatically.
The status of package can be defined by the ``package_ensure`` parameter.

View File

@ -10,6 +10,13 @@ describe 'aodh::expirer' do
it { is_expected.to contain_class('aodh::deps') } it { is_expected.to contain_class('aodh::deps') }
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
it 'installs aodh-expirer package' do
is_expected.to contain_package(platform_params[:expirer_package_name]).with(
:ensure => 'present',
:tag => ['openstack', 'aodh-package']
)
end
it { is_expected.to contain_cron('aodh-expirer').with( it { is_expected.to contain_cron('aodh-expirer').with(
:ensure => 'present', :ensure => 'present',
:command => 'aodh-expirer', :command => 'aodh-expirer',
@ -35,6 +42,13 @@ describe 'aodh::expirer' do
it { is_expected.to contain_class('aodh::deps') } it { is_expected.to contain_class('aodh::deps') }
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
it 'installs aodh-expirer package' do
is_expected.to contain_package(platform_params[:expirer_package_name]).with(
:ensure => 'present',
:tag => ['openstack', 'aodh-package']
)
end
it { is_expected.to contain_cron('aodh-expirer').with( it { is_expected.to contain_cron('aodh-expirer').with(
:ensure => 'absent', :ensure => 'absent',
:command => 'sleep `expr ${RANDOM} \\% 300`; aodh-expirer', :command => 'sleep `expr ${RANDOM} \\% 300`; aodh-expirer',
@ -59,6 +73,14 @@ describe 'aodh::expirer' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :expirer_package_name => 'aodh-expirer' }
when 'RedHat'
{ :expirer_package_name => 'openstack-aodh-expirer' }
end
end
it_behaves_like 'aodh::expirer' it_behaves_like 'aodh::expirer'
end end
end end