From 9befc700a1b086b6f81fbb959a4c7520e83be5ad Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Wed, 7 Jan 2015 13:45:50 +0000 Subject: [PATCH] Allow overriding ensure for glance-registry The main glance class allows overriding the package_ensure setting from the default of 'present', but on Debian based systems glance-registry is a separate package. This package updates the glance::registry class to allow overriding the package ensure there also. Change-Id: I6182836728102e827f9d5a3beef4964dd6e8d7f9 --- manifests/registry.pp | 9 ++++++++- spec/classes/glance_registry_spec.rb | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/manifests/registry.pp b/manifests/registry.pp index 761b7ca2..84e8155a 100644 --- a/manifests/registry.pp +++ b/manifests/registry.pp @@ -7,6 +7,11 @@ # [*keystone_password*] # (required) The keystone password for administrative user # +# [*package_ensure*] +# (optional) Ensure state for package. Defaults to 'present'. On RedHat +# platforms this setting is ignored and the setting from the glance class is +# used because there is only one glance package. +# # [*verbose*] # (optional) Enable verbose logs (true|false). Defaults to false. # @@ -106,6 +111,7 @@ # class glance::registry( $keystone_password, + $package_ensure = 'present', $verbose = false, $debug = false, $bind_host = '0.0.0.0', @@ -142,7 +148,8 @@ class glance::registry( } if ( $glance::params::api_package_name != $glance::params::registry_package_name ) { - ensure_packages([$glance::params::registry_package_name]) + ensure_packages( [$glance::params::registry_package_name], + { ensure => $package_ensure }) } Package[$glance::params::registry_package_name] -> File['/etc/glance/'] diff --git a/spec/classes/glance_registry_spec.rb b/spec/classes/glance_registry_spec.rb index b113d052..8b6dcbd1 100644 --- a/spec/classes/glance_registry_spec.rb +++ b/spec/classes/glance_registry_spec.rb @@ -296,9 +296,15 @@ describe 'glance::registry' do let :facts do { :osfamily => 'Debian' } end - let(:params) { default_params } - it {should contain_package('glance-registry')} + # We only test this on Debian platforms, since on RedHat there isn't a + # separate package for glance registry. + ['present', 'latest'].each do |package_ensure| + context "with package_ensure '#{package_ensure}'" do + let(:params) { default_params.merge({ :package_ensure => package_ensure })} + it {should contain_package('glance-registry').with_ensure(package_ensure)} + end + end end describe 'on RedHat platforms' do