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: I1ee5f6f36dce3429261b77a4c91b4732ced4a591
This commit is contained in:
Takashi Kajinami 2020-10-12 14:04:26 +09:00
parent bded1a8c1e
commit 6f833db0a2
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 barbican::keystone::authtoken(
$password = $::os_service_default,
$username = 'barbican',
@ -224,6 +228,7 @@ class barbican::keystone::authtoken(
$service_token_roles_required = $::os_service_default,
$service_type = $::os_service_default,
$interface = $::os_service_default,
$params = {},
) {
include barbican::deps
@ -232,7 +237,10 @@ class barbican::keystone::authtoken(
fail('Please set password for barbican service user')
}
keystone::resource::authtoken { 'barbican_config':
keystone::resource::authtoken {
'barbican_config':
* => $params;
default:
username => $username,
password => $password,
project_name => $project_name,
@ -268,6 +276,6 @@ class barbican::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

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