Add ability to configure endpoint_type in openrc
* Add the ability to configure the endpoint type used by the client * Refactor to use a template for the generation of openrc Change-Id: Id4b214373676488930be2066ad96ab3261ded909
This commit is contained in:
@@ -1,38 +1,58 @@
|
|||||||
|
# == Class: openstack::auth_file
|
||||||
#
|
#
|
||||||
# Creates an auth file that can be used to export
|
# Creates an auth file that can be used to export
|
||||||
# environment variables that can be used to authenticate
|
# environment variables that can be used to authenticate
|
||||||
# against a keystone server.
|
# against a keystone server.
|
||||||
#
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*admin_password*]
|
||||||
|
# (required) Admin password.
|
||||||
|
# [*controller_node*]
|
||||||
|
# (optional) Keystone address. Defaults to '127.0.0.1'.
|
||||||
|
# [*keystone_admin_token*]
|
||||||
|
# (optional) Admin token.
|
||||||
|
# NOTE: This setting will trigger a warning from keystone.
|
||||||
|
# Authentication credentials will be ignored by keystone client
|
||||||
|
# in favor of token authentication. Defaults to undef.
|
||||||
|
# [*admin_user*]
|
||||||
|
# (optional) Defaults to 'admin'.
|
||||||
|
# [*admin_tenant*]
|
||||||
|
# (optional) Defaults to 'admin'.
|
||||||
|
# [*region_name*]
|
||||||
|
# (optional) Defaults to 'RegionOne'.
|
||||||
|
# [*use_no_cache*]
|
||||||
|
# (optional) Do not use the auth token cache. Defaults to true.
|
||||||
|
# [*cinder_endpoint_type*]
|
||||||
|
# (optional) Defaults to 'publicURL'.
|
||||||
|
# [*glance_endpoint_type*]
|
||||||
|
# (optional) Defaults to 'publicURL'.
|
||||||
|
# [*keystone_endpoint_type*]
|
||||||
|
# (optional) Defaults to 'publicURL'.
|
||||||
|
# [*nova_endpoint_type*]
|
||||||
|
# (optional) Defaults to 'publicURL'.
|
||||||
|
# [*quantum_endpoint_type*]
|
||||||
|
# (optional) Defaults to 'publicURL'.
|
||||||
|
#
|
||||||
class openstack::auth_file(
|
class openstack::auth_file(
|
||||||
$controller_node = '127.0.0.1',
|
$admin_password,
|
||||||
$keystone_admin_token = undef,
|
$controller_node = '127.0.0.1',
|
||||||
$admin_user = 'admin',
|
$keystone_admin_token = undef,
|
||||||
$admin_password = undef,
|
$admin_user = 'admin',
|
||||||
$admin_tenant = 'admin',
|
$admin_tenant = 'admin',
|
||||||
$region_name = 'RegionOne',
|
$region_name = 'RegionOne',
|
||||||
$use_no_cache = true
|
$use_no_cache = true,
|
||||||
|
$cinder_endpoint_type = 'publicURL',
|
||||||
|
$glance_endpoint_type = 'publicURL',
|
||||||
|
$keystone_endpoint_type = 'publicURL',
|
||||||
|
$nova_endpoint_type = 'publicURL',
|
||||||
|
$quantum_endpoint_type = 'publicURL',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if ($keystone_admin_token) {
|
file { '/root/openrc':
|
||||||
file { '/root/openrc':
|
owner => 'root',
|
||||||
content =>
|
group => 'root',
|
||||||
"
|
mode => '0700',
|
||||||
export OS_SERVICE_TOKEN=${keystone_admin_token}
|
content => template("${module_name}/openrc.erb")
|
||||||
export OS_SERVICE_ENDPOINT=http://${controller_node}:35357/v2.0/
|
|
||||||
"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file { '/root/openrc':
|
|
||||||
content =>
|
|
||||||
"
|
|
||||||
export OS_NO_CACHE=${use_no_cache}
|
|
||||||
export OS_TENANT_NAME=${admin_tenant}
|
|
||||||
export OS_USERNAME=${admin_user}
|
|
||||||
export OS_PASSWORD='${admin_password}'
|
|
||||||
export OS_AUTH_URL=\"http://${controller_node}:5000/v2.0/\"
|
|
||||||
export OS_AUTH_STRATEGY=keystone
|
|
||||||
export OS_REGION_NAME=${region_name}
|
|
||||||
"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,36 +9,55 @@ describe 'openstack::auth_file' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should create a openrc file' do
|
it 'should create a openrc file' do
|
||||||
should contain_file('/root/openrc').with_content(
|
verify_contents(subject, '/root/openrc', [
|
||||||
'
|
'export OS_NO_CACHE=true',
|
||||||
export OS_NO_CACHE=true
|
'export OS_TENANT_NAME=admin',
|
||||||
export OS_TENANT_NAME=admin
|
'export OS_USERNAME=admin',
|
||||||
export OS_USERNAME=admin
|
'export OS_PASSWORD=admin',
|
||||||
export OS_PASSWORD=\'admin\'
|
'export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/',
|
||||||
export OS_AUTH_URL="http://127.0.0.1:5000/v2.0/"
|
'export OS_AUTH_STRATEGY=keystone',
|
||||||
export OS_AUTH_STRATEGY=keystone
|
'export OS_REGION_NAME=RegionOne',
|
||||||
export OS_REGION_NAME=RegionOne
|
'export CINDER_ENDPOINT_TYPE=publicURL',
|
||||||
'
|
'export GLANCE_ENDPOINT_TYPE=publicURL',
|
||||||
)
|
'export KEYSTONE_ENDPOINT_TYPE=publicURL',
|
||||||
|
'export NOVA_ENDPOINT_TYPE=publicURL',
|
||||||
|
'export QUANTUM_ENDPOINT_TYPE=publicURL'
|
||||||
|
])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when overridding' do
|
describe 'when overriding parameters' do
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:controller_node => '127.0.0.2',
|
:controller_node => '127.0.0.2',
|
||||||
:keystone_admin_token => 'keystone',
|
:admin_password => 'admin',
|
||||||
}
|
:keystone_admin_token => 'keystone',
|
||||||
end
|
:cinder_endpoint_type => 'privateURL',
|
||||||
|
:glance_endpoint_type => 'privateURL',
|
||||||
|
:keystone_endpoint_type => 'privateURL',
|
||||||
|
:nova_endpoint_type => 'privateURL',
|
||||||
|
:quantum_endpoint_type => 'privateURL',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
it 'should create a openrc file' do
|
it 'should create a openrc file' do
|
||||||
should contain_file('/root/openrc').with_content(
|
verify_contents(subject, '/root/openrc', [
|
||||||
'
|
'export OS_SERVICE_TOKEN=keystone',
|
||||||
export OS_SERVICE_TOKEN=keystone
|
'export OS_SERVICE_ENDPOINT=http://127.0.0.2:35357/v2.0/',
|
||||||
export OS_SERVICE_ENDPOINT=http://127.0.0.2:35357/v2.0/
|
'export OS_NO_CACHE=true',
|
||||||
'
|
'export OS_TENANT_NAME=admin',
|
||||||
)
|
'export OS_USERNAME=admin',
|
||||||
end
|
'export OS_PASSWORD=admin',
|
||||||
|
'export OS_AUTH_URL=http://127.0.0.2:5000/v2.0/',
|
||||||
|
'export OS_AUTH_STRATEGY=keystone',
|
||||||
|
'export OS_REGION_NAME=RegionOne',
|
||||||
|
'export CINDER_ENDPOINT_TYPE=privateURL',
|
||||||
|
'export GLANCE_ENDPOINT_TYPE=privateURL',
|
||||||
|
'export KEYSTONE_ENDPOINT_TYPE=privateURL',
|
||||||
|
'export NOVA_ENDPOINT_TYPE=privateURL',
|
||||||
|
'export QUANTUM_ENDPOINT_TYPE=privateURL'
|
||||||
|
])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
17
templates/openrc.erb
Normal file
17
templates/openrc.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
<% if @keystone_admin_token -%>
|
||||||
|
export OS_SERVICE_TOKEN=<%= @keystone_admin_token %>
|
||||||
|
export OS_SERVICE_ENDPOINT=http://<%= @controller_node %>:35357/v2.0/
|
||||||
|
<% end -%>
|
||||||
|
export OS_NO_CACHE=<%= @use_no_cache %>
|
||||||
|
export OS_TENANT_NAME=<%= @admin_tenant %>
|
||||||
|
export OS_USERNAME=<%= @admin_user %>
|
||||||
|
export OS_PASSWORD=<%= @admin_password %>
|
||||||
|
export OS_AUTH_URL=http://<%= @controller_node %>:5000/v2.0/
|
||||||
|
export OS_AUTH_STRATEGY=keystone
|
||||||
|
export OS_REGION_NAME=<%= @region_name %>
|
||||||
|
export CINDER_ENDPOINT_TYPE=<%= @cinder_endpoint_type %>
|
||||||
|
export GLANCE_ENDPOINT_TYPE=<%= @glance_endpoint_type %>
|
||||||
|
export KEYSTONE_ENDPOINT_TYPE=<%= @keystone_endpoint_type %>
|
||||||
|
export NOVA_ENDPOINT_TYPE=<%= @nova_endpoint_type %>
|
||||||
|
export QUANTUM_ENDPOINT_TYPE=<%= @quantum_endpoint_type %>
|
Reference in New Issue
Block a user