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: Iae359ee38cac10190f9813b14cd3a2f92a59d1b6
This commit is contained in:
Takashi Kajinami 2021-08-27 15:08:50 +09:00
parent 2ba372a398
commit 8b8601618a
2 changed files with 58 additions and 37 deletions

View File

@ -187,6 +187,10 @@
# "public", "internal" or "admin". # "public", "internal" or "admin".
# Defaults to $::os_service_default. # 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 zaqar::keystone::authtoken( class zaqar::keystone::authtoken(
$username = 'zaqar', $username = 'zaqar',
$password = $::os_service_default, $password = $::os_service_default,
@ -224,6 +228,7 @@ class zaqar::keystone::authtoken(
$service_token_roles_required = $::os_service_default, $service_token_roles_required = $::os_service_default,
$service_type = $::os_service_default, $service_type = $::os_service_default,
$interface = $::os_service_default, $interface = $::os_service_default,
$params = {}
) { ) {
include zaqar::deps include zaqar::deps
@ -232,7 +237,10 @@ class zaqar::keystone::authtoken(
fail('Please set password for Zaqar service user') fail('Please set password for Zaqar service user')
} }
keystone::resource::authtoken { 'zaqar_config': keystone::resource::authtoken {
'zaqar_config':
* => $params;
default:
username => $username, username => $username,
password => $password, password => $password,
project_name => $project_name, project_name => $project_name,
@ -268,6 +276,6 @@ class zaqar::keystone::authtoken(
service_token_roles => $service_token_roles, service_token_roles => $service_token_roles,
service_token_roles_required => $service_token_roles_required, service_token_roles_required => $service_token_roles_required,
service_type => $service_type, service_type => $service_type,
interface => $interface, interface => $interface;
} }
} }

View File

@ -133,6 +133,19 @@ describe 'zaqar::keystone::authtoken' do
is_expected.to contain_package('python-memcache') is_expected.to contain_package('python-memcache')
end end
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_zaqar_config('keystone_authtoken/username').with_value(params[:params]['username'])
end
end
end end
on_supported_os({ on_supported_os({