Use a 'params' hash for authtoken parameters

This change adds the 'params' hash in authtoken class, to implement
the same functionality as the one recently introduced into
puppet-nova[1].

[1] 5c38281e1b698f157f03bf1815733277c541c30b

Change-Id: Id291959862bfe82cc1800e9bc7759b52006a10b7
This commit is contained in:
Takashi Kajinami 2021-08-26 21:30:34 +09:00
parent d0c1bfd14e
commit c65c7c3782
2 changed files with 57 additions and 37 deletions
manifests/keystone
spec/classes

@ -191,6 +191,10 @@
# "public", "internal" or "admin".
# Defaults to $::os_service_default.
#
# [*params*]
# (Optional) Hash of additional parameters to pass through to the keystone
# authtoken class. Values set here override the individual parameters above.
#
class cinder::keystone::authtoken(
$username = 'cinder',
$password = $::os_service_default,
@ -228,6 +232,7 @@ class cinder::keystone::authtoken(
$service_token_roles_required = $::os_service_default,
$service_type = $::os_service_default,
$interface = $::os_service_default,
$params = {},
) {
include cinder::deps
@ -236,7 +241,10 @@ class cinder::keystone::authtoken(
fail('Please set password for cinder service user')
}
keystone::resource::authtoken { 'cinder_config':
keystone::resource::authtoken {
'cinder_config':
* => $params;
default:
username => $username,
password => $password,
project_name => $project_name,
@ -272,6 +280,6 @@ class cinder::keystone::authtoken(
service_token_roles => $service_token_roles,
service_token_roles_required => $service_token_roles_required,
service_type => $service_type,
interface => $interface,
interface => $interface;
}
}

@ -132,6 +132,18 @@ describe 'cinder::keystone::authtoken' do
is_expected.to contain_package('python-memcache')
end
end
context 'when overriding parameters via params hash' do
before do
params.merge!({
:username => 'myuser',
:params => { 'username' => 'myotheruser' },
})
end
it 'configure keystone_authtoken' do
is_expected.to contain_cinder_config('keystone_authtoken/username').with_value(params[:params]['username'])
end
end
end
on_supported_os({