Refactor of glance::keystone::auth
This refactor of glance::keystone::auth adds additional class parameters to make it easier to configure the resulting keystone objects. Adds the following class parameters: - admin_address = '127.0.0.1', - internal_address = '127.0.0.1', - region Removes the following parameters: - address (which has been replaced by the above parameters) Renames the following paramters: - service => service_type
This commit is contained in:
parent
622143771b
commit
b454b902cf
|
@ -1,9 +1,28 @@
|
|||
#
|
||||
# Sets up glance users, service and endpoint
|
||||
#
|
||||
# == Parameters:
|
||||
#
|
||||
# $auth_name :: identifier used for all keystone objects related to glance.
|
||||
# Optional. Defaults to glance.
|
||||
# $password :: password for glance user. Optional. Defaults to glance_password.
|
||||
# $service_type :: type of service to create. Optional. Defaults to image.
|
||||
# $public_address :: Public address for endpoint. Optional. Defaults to 127.0.0.1.
|
||||
# $admin_address :: Admin address for endpoint. Optional. Defaults to 127.0.0.1.
|
||||
# $inernal_address :: Internal address for endpoint. Optional. Defaults to 127.0.0.1.
|
||||
# $port :: Port for endpoint. Needs to match glance api service port. Optional.
|
||||
# Defaults to 9292.
|
||||
# $region :: Region where endpoint is set.
|
||||
#
|
||||
class glance::keystone::auth(
|
||||
$auth_name = 'glance',
|
||||
$password = 'glance_password',
|
||||
$service = 'image',
|
||||
$address = '127.0.0.1',
|
||||
$port = '9292'
|
||||
$auth_name = 'glance',
|
||||
$password = 'glance_password',
|
||||
$service_type = 'image',
|
||||
$public_address = '127.0.0.1',
|
||||
$admin_address = '127.0.0.1',
|
||||
$internal_address = '127.0.0.1',
|
||||
$port = '9292',
|
||||
$region = 'RegionOne'
|
||||
) {
|
||||
|
||||
Keystone_user_role["${auth_name}@services"] ~> Service <| name == 'glance-registry' |>
|
||||
|
@ -19,15 +38,15 @@ class glance::keystone::auth(
|
|||
}
|
||||
keystone_service { $auth_name:
|
||||
ensure => present,
|
||||
type => 'image',
|
||||
type => $service_type,
|
||||
description => "Openstack Image Service",
|
||||
}
|
||||
}
|
||||
keystone_endpoint { $auth_name:
|
||||
ensure => present,
|
||||
region => 'RegionOne',
|
||||
public_url => "http://${address}:${port}/v1",
|
||||
admin_url => "http://${address}:${port}/v1",
|
||||
internal_url => "http://${address}:${port}/v1",
|
||||
region => $region,
|
||||
public_url => "http://${public_address}:${port}/v1",
|
||||
admin_url => "http://${admin_address}:${port}/v1",
|
||||
internal_url => "http://${internal_address}:${port}/v1",
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'glance::keystone::auth' do
|
||||
|
||||
describe 'with defaults' do
|
||||
|
||||
it { should contain_keystone_user('glance').with(
|
||||
:ensure => 'present',
|
||||
:password => 'glance_password'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_user_role('glance@services').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_service('glance').with(
|
||||
:ensure => 'present',
|
||||
:type => 'image',
|
||||
:description => 'Openstack Image Service'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_endpoint('glance').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionOne',
|
||||
:public_url => 'http://127.0.0.1:9292/v1',
|
||||
:admin_url => 'http://127.0.0.1:9292/v1',
|
||||
:internal_url => 'http://127.0.0.1:9292/v1'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'when auth_type, password, and service_type are overridden' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:auth_name => 'glancey',
|
||||
:password => 'password',
|
||||
:service_type => 'imagey'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('glancey').with(
|
||||
:ensure => 'present',
|
||||
:password => 'password'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_user_role('glancey@services').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_service('glancey').with(
|
||||
:ensure => 'present',
|
||||
:type => 'imagey',
|
||||
:description => 'Openstack Image Service'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
describe 'when address, region and port are overridden' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:public_address => '10.0.0.1',
|
||||
:admin_address => '10.0.0.2',
|
||||
:internal_address => '10.0.0.3',
|
||||
:port => '9393',
|
||||
:region => 'RegionTwo'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_keystone_endpoint('glance').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionTwo',
|
||||
:public_url => 'http://10.0.0.1:9393/v1',
|
||||
:admin_url => 'http://10.0.0.2:9393/v1',
|
||||
:internal_url => 'http://10.0.0.3:9393/v1'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue