diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 3d910356..a49a79b7 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -14,7 +14,7 @@ # Username for Cinder service. Optional. Defaults to 'cinder'. # # [*auth_name_v2*] -# Username for Cinder v2 service. Optional. Defaults to 'cinder2'. +# Username for Cinder v2 service. Optional. Defaults to 'cinderv2'. # # [*configure_endpoint*] # Should Cinder endpoint be configured? Optional. Defaults to 'true'. @@ -30,6 +30,16 @@ # Should the admin role be configured for the service user? # Optional. Defaults to 'true'. # +# [*service_name*] +# (optional) Name of the service. +# Defaults to the value of auth_name, but must differ from the value +# of service_name_v2. +# +# [*service_name_v2*] +# (optional) Name of the v2 service. +# Defaults to the value of auth_name_v2, but must differ from the value +# of service_name. +# # [*service_type*] # Type of service. Optional. Defaults to 'volume'. # @@ -76,6 +86,8 @@ class cinder::keystone::auth ( $configure_endpoint_v2 = true, $configure_user = true, $configure_user_role = true, + $service_name = undef, + $service_name_v2 = undef, $service_type = 'volume', $service_type_v2 = 'volumev2', $public_address = '127.0.0.1', @@ -88,15 +100,29 @@ class cinder::keystone::auth ( $admin_protocol = 'http', $internal_protocol = 'http' ) { + if $service_name { + $real_service_name = $service_name + } else { + $real_service_name = $auth_name + } + if $service_name_v2 { + $real_service_name_v2 = $service_name_v2 + } else { + $real_service_name_v2 = $auth_name_v2 + } - keystone::resource::service_identity { $auth_name: + if $real_service_name == $real_service_name_v2 { + fail('cinder::keystone::auth parameters service_name and service_name_v2 must be different.') + } + keystone::resource::service_identity { 'cinder': configure_user => $configure_user, configure_user_role => $configure_user_role, configure_endpoint => $configure_endpoint, service_type => $service_type, service_description => 'Cinder Service', - service_name => $auth_name, + service_name => $real_service_name, region => $region, + auth_name => $auth_name, password => $password, email => $email, tenant => $tenant, @@ -105,13 +131,13 @@ class cinder::keystone::auth ( internal_url => "${internal_protocol}://${internal_address}:${port}/${volume_version}/%(tenant_id)s", } - keystone::resource::service_identity { $auth_name_v2: + keystone::resource::service_identity { 'cinderv2': configure_user => false, configure_user_role => false, configure_endpoint => $configure_endpoint_v2, service_type => $service_type_v2, service_description => 'Cinder Service v2', - service_name => $auth_name_v2, + service_name => $real_service_name_v2, region => $region, public_url => "${public_protocol}://${public_address}:${port}/v2/%(tenant_id)s", admin_url => "${admin_protocol}://${admin_address}:${port}/v2/%(tenant_id)s", diff --git a/spec/classes/cinder_keystone_auth_spec.rb b/spec/classes/cinder_keystone_auth_spec.rb index 9c3690b7..b506a2cb 100644 --- a/spec/classes/cinder_keystone_auth_spec.rb +++ b/spec/classes/cinder_keystone_auth_spec.rb @@ -132,4 +132,22 @@ describe 'cinder::keystone::auth' do end + describe 'when overriding service names' do + + let :params do + req_params.merge( + :service_name => 'cinder_service', + :service_name_v2 => 'cinder_service_v2', + ) + end + + it { should contain_keystone_user('cinder') } + it { should contain_keystone_user_role('cinder@services') } + it { should contain_keystone_service('cinder_service') } + it { should contain_keystone_service('cinder_service_v2') } + it { should contain_keystone_endpoint('RegionOne/cinder_service') } + it { should contain_keystone_endpoint('RegionOne/cinder_service_v2') } + + end + end