make openstackclient package name configurable

Change-Id: Ie7d770af6d1238c3f68b7c743e8fa5255a9a5995
This commit is contained in:
Benedikt Trefzer 2018-08-31 17:26:19 +02:00
parent daf881e09c
commit a39a44faf9
3 changed files with 32 additions and 7 deletions

View File

@ -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'
})

12
manifests/params.pp Normal file
View File

@ -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',
}
}

View File

@ -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({