diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 516bc3af..05549d49 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -49,13 +49,11 @@ # # [*service_name*] # (optional) Name of the service. -# Defaults to the value of auth_name, but must differ from the value -# of service_name_s3. +# Defaults to 'swift' # # [*service_name_s3*] # (optional) Name of the s3 service. -# Defaults to the value of auth_name_s3, but must differ from the value -# of service_name. +# Defaults to 'swift_s3' # # [*service_description*] # (optional) Description for keystone service. @@ -157,8 +155,8 @@ class swift::keystone::auth( $email = 'swift@localhost', $region = 'RegionOne', $operator_roles = ['admin', 'SwiftOperator'], - $service_name = undef, - $service_name_s3 = undef, + $service_name = 'swift', + $service_name_s3 = 'swift_s3', $service_description = 'Openstack Object-Store Service', $service_description_s3 = 'Openstack S3 Service', $configure_endpoint = true, @@ -277,27 +275,24 @@ class swift::keystone::auth( $internal_url_s3_real = $internal_url_s3 } - $real_service_name = pick($service_name, $auth_name) - $real_service_name_s3 = pick($service_name_s3, "${auth_name}_s3") - - if $real_service_name == $real_service_name_s3 { - fail('cinder::keystone::auth parameters service_name and service_name_s3 must be different.') + if $service_name == $service_name_s3 { + fail('swift::keystone::auth parameters service_name and service_name_s3 must be different.') } # Establish that keystone auth and endpoints are properly setup before # managing any type of swift related service. if $configure_endpoint { - Keystone_endpoint["${region}/${real_service_name}::object-store"] -> Swift::Service<||> + Keystone_endpoint["${region}/${service_name}::object-store"] -> Swift::Service<||> } if $configure_s3_endpoint { - Keystone_endpoint["${region}/${real_service_name_s3}::s3"] -> Swift::Service<||> + Keystone_endpoint["${region}/${service_name_s3}::s3"] -> Swift::Service<||> } keystone::resource::service_identity { 'swift': configure_endpoint => $configure_endpoint, configure_user => $configure_user, configure_user_role => $configure_user_role, - service_name => $real_service_name, + service_name => $service_name, service_type => 'object-store', service_description => $service_description, region => $region, @@ -315,7 +310,7 @@ class swift::keystone::auth( configure_user_role => false, configure_endpoint => $configure_s3_endpoint, configure_service => $configure_s3_endpoint, - service_name => $real_service_name_s3, + service_name => $service_name_s3, service_type => 's3', service_description => $service_description_s3, region => $region, diff --git a/releasenotes/notes/keystone-auth-name-d2f0ea23d797b555.yaml b/releasenotes/notes/keystone-auth-name-d2f0ea23d797b555.yaml new file mode 100644 index 00000000..736dff47 --- /dev/null +++ b/releasenotes/notes/keystone-auth-name-d2f0ea23d797b555.yaml @@ -0,0 +1,5 @@ +fixes: + - The keystone auth class has been updated to provide a default service_name + to allow a user to specify a custom auth_name that may not contain the + name of the service. + diff --git a/spec/classes/swift_keystone_auth_spec.rb b/spec/classes/swift_keystone_auth_spec.rb index b23fee82..1e5e3b23 100644 --- a/spec/classes/swift_keystone_auth_spec.rb +++ b/spec/classes/swift_keystone_auth_spec.rb @@ -21,6 +21,8 @@ describe 'swift::keystone::auth' do :public_url_s3 => 'http://127.0.0.1:8080', :admin_url_s3 => 'http://127.0.0.1:8080', :internal_url_s3 => 'http://127.0.0.1:8080', + :service_name => 'swift', + :service_name_s3 => 'swift_s3', } end @@ -57,14 +59,14 @@ describe 'swift::keystone::auth' do it { is_expected.to contain_keystone_role(role_name).with_ensure('present') } end - it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}::object-store").with( + it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{default_params[:service_name]}::object-store").with( :ensure => 'present', :public_url => params[:public_url], :admin_url => params[:admin_url], :internal_url => params[:internal_url], )} - it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}_s3::s3").with( + it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{default_params[:service_name_s3]}::s3").with( :ensure => 'present', :public_url => params[:public_url_s3], :admin_url => params[:admin_url_s3], @@ -107,6 +109,8 @@ describe 'swift::keystone::auth' do :internal_protocol => 'https', :internal_address => 'internal.example.org', :endpoint_prefix => 'KEY_AUTH', + :service_name => 'swift', + :service_name_s3 => 'swift_s3' }) end @@ -114,14 +118,14 @@ describe 'swift::keystone::auth' do default_params.merge( params ) end - it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}::object-store").with( + it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:service_name]}::object-store").with( :ensure => 'present', :public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:public_port]}/v1/#{p[:endpoint_prefix]}_%(tenant_id)s", :admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}", :internal_url => "#{p[:internal_protocol]}://#{p[:internal_address]}:#{p[:port]}/v1/#{p[:endpoint_prefix]}_%(tenant_id)s" )} - it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}_s3::s3").with( + it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:service_name_s3]}::s3").with( :ensure => 'present', :public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}", :admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}", @@ -136,10 +140,11 @@ describe 'swift::keystone::auth' do end context 'when user configuration is set to default' do + it { is_expected.to contain_keystone_user(p[:auth_name]).with( :ensure => 'present', :password => p[:password], - :email => p[:email] + :email => p[:email], )} it { is_expected.to contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}").with( @@ -147,13 +152,13 @@ describe 'swift::keystone::auth' do :roles => ['admin'], )} - it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with( + it { is_expected.to contain_keystone_service("swift::object-store").with( :ensure => 'present', :type => 'object-store', :description => 'Openstack Object-Store Service' )} - it { is_expected.to contain_keystone_service("#{p[:auth_name]}_s3::s3").with( + it { is_expected.to contain_keystone_service('swift_s3::s3').with( :ensure => 'present', :type => 's3', :description => 'Openstack S3 Service' @@ -168,7 +173,7 @@ describe 'swift::keystone::auth' do it { is_expected.to_not contain_keystone_user(p[:auth_name]) } it { is_expected.to contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}") } - it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with( + it { is_expected.to contain_keystone_service('swift::object-store').with( :ensure => 'present', :type => 'object-store', :description => 'Openstack Object-Store Service' @@ -186,7 +191,7 @@ describe 'swift::keystone::auth' do it { is_expected.to_not contain_keystone_user(p[:auth_name]) } it { is_expected.to_not contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}") } - it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with( + it { is_expected.to contain_keystone_service('swift::object-store').with( :ensure => 'present', :type => 'object-store', :description => 'Openstack Object-Store Service' @@ -210,9 +215,6 @@ describe 'swift::keystone::auth' do it_configures 'swift keystone auth' end - - - context 'when overriding service name' do before do params.merge!({