commit 007d3a82f6bd72361066ea731a94a67c1b4d5f2b Author: Takashi Kajinami Date: Sat Oct 3 23:02:38 2020 +0900 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 diff --git a/manifests/expirer.pp b/manifests/expirer.pp index f9e19dc..24bc192 100644 --- a/manifests/expirer.pp +++ b/manifests/expirer.pp @@ -9,6 +9,10 @@ # (optional) The state of cron job. # Defaults to present. # +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# # [*minute*] # (optional) Defaults to '1'. # @@ -31,18 +35,24 @@ # Defaults to 0. # class aodh::expirer ( - $ensure = 'present', - $minute = 1, - $hour = 0, - $monthday = '*', - $month = '*', - $weekday = '*', - $maxdelay = 0, + $ensure = 'present', + $package_ensure = 'present', + $minute = 1, + $hour = 0, + $monthday = '*', + $month = '*', + $weekday = '*', + $maxdelay = 0, ) { include aodh::params include aodh::deps + ensure_resource( 'package', [$::aodh::params::expirer_package_name], + { ensure => $package_ensure, + tag => ['openstack', 'aodh-package'] } + ) + if $maxdelay == 0 { $sleep = '' } else { diff --git a/releasenotes/notes/expirer-package-a318c98f11722956.yaml b/releasenotes/notes/expirer-package-a318c98f11722956.yaml new file mode 100644 index 0000000..0174dff --- /dev/null +++ b/releasenotes/notes/expirer-package-a318c98f11722956.yaml @@ -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. diff --git a/spec/classes/aodh_expirer_spec.rb b/spec/classes/aodh_expirer_spec.rb index 033797f..31b6792 100644 --- a/spec/classes/aodh_expirer_spec.rb +++ b/spec/classes/aodh_expirer_spec.rb @@ -10,6 +10,13 @@ describe 'aodh::expirer' do it { is_expected.to contain_class('aodh::deps') } 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( :ensure => 'present', :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::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( :ensure => 'absent', :command => 'sleep `expr ${RANDOM} \\% 300`; aodh-expirer', @@ -59,6 +73,14 @@ describe 'aodh::expirer' do facts.merge!(OSDefaults.get_facts()) 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' end end