diff --git a/manifests/openstackclient.pp b/manifests/openstackclient.pp index 47ba1148..ade510d2 100644 --- a/manifests/openstackclient.pp +++ b/manifests/openstackclient.pp @@ -8,16 +8,16 @@ # (Optional) Ensure state of the openstackclient package. # Defaults to 'present' # +# [*package_name*] +# (Optional) The name of the package to install +# Defaults to $::openstacklib::params::openstackclient_package_name +# class openstacklib::openstackclient( + $package_name = $::openstacklib::params::openstackclient_package_name, $package_ensure = 'present', -){ +) inherits ::openstacklib::params { - $openstackclient_package_name = $::os_package_type ? { - 'debian' => 'python3-openstackclient', - default => 'python-openstackclient', - } - - ensure_packages($openstackclient_package_name, { + ensure_packages($package_name, { 'ensure' => $package_ensure, 'tag' => 'openstack' }) diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 00000000..69f2b2b8 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,12 @@ +# == Class: openstacklib::params +# +# These parameters need to be accessed from several locations and +# should be considered to be constant +# +class openstacklib::params { + + $openstackclient_package_name = $::os_package_type ? { + 'debian' => 'python3-openstackclient', + default => 'python-openstackclient', + } +} diff --git a/spec/classes/openstacklib_openstackclient_spec.rb b/spec/classes/openstacklib_openstackclient_spec.rb index cfcfdde0..201db1d8 100644 --- a/spec/classes/openstacklib_openstackclient_spec.rb +++ b/spec/classes/openstacklib_openstackclient_spec.rb @@ -11,6 +11,19 @@ describe 'openstacklib::openstackclient' do ) end end + + context 'with non default package name' do + let :params do + { :package_name => 'my-openstackclient' } + end + + it 'installs my-openstackclient' do + is_expected.to contain_package('my-openstackclient').with( + :ensure => 'present', + :tag => 'openstack' + ) + end + end end on_supported_os({