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: I9a3a1ae0059afc44f71c322c2452776f293a2089
This commit is contained in:
Takashi Kajinami 2020-10-11 21:37:01 +09:00
parent 8d0b2fb637
commit d919628ed1
2 changed files with 58 additions and 37 deletions

View File

@ -187,6 +187,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 aodh::keystone::authtoken(
$username = 'aodh',
$password = $::os_service_default,
@ -224,6 +228,7 @@ class aodh::keystone::authtoken(
$service_token_roles_required = $::os_service_default,
$service_type = $::os_service_default,
$interface = $::os_service_default,
$params = {},
) {
include aodh::deps
@ -232,7 +237,10 @@ class aodh::keystone::authtoken(
fail('Please set password for Aodh service user')
}
keystone::resource::authtoken { 'aodh_config':
keystone::resource::authtoken {
'aodh_config':
* => $params;
default:
username => $username,
password => $password,
project_name => $project_name,
@ -268,6 +276,6 @@ class aodh::keystone::authtoken(
service_token_roles => $service_token_roles,
service_token_roles_required => $service_token_roles_required,
service_type => $service_type,
interface => $interface,
interface => $interface;
}
}

View File

@ -133,6 +133,19 @@ describe 'aodh::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_aodh_config('keystone_authtoken/username').with_value(params[:params]['username'])
end
end
end
on_supported_os({