2019-11-02 12:32:24 +01:00
|
|
|
# == Class: keystone::bootstrap
|
|
|
|
#
|
|
|
|
# Bootstrap keystone with keystone-manage bootstrap.
|
|
|
|
#
|
|
|
|
# === Parameters
|
|
|
|
#
|
|
|
|
# [*password*]
|
|
|
|
# (Optional) The password for the user.
|
|
|
|
# WARNING: This parameter will be required in a future release.
|
|
|
|
# Defaults to undef
|
|
|
|
#
|
|
|
|
# [*username*]
|
|
|
|
# (Optional) The username.
|
|
|
|
# Defaults to 'admin'
|
|
|
|
#
|
|
|
|
# [*email*]
|
|
|
|
# (Optional) The email for the user.
|
|
|
|
# Defaults to 'admin@localhost'
|
|
|
|
#
|
|
|
|
# [*project_name*]
|
|
|
|
# (Optional) The project name.
|
|
|
|
# Defaults to 'admin'
|
|
|
|
#
|
|
|
|
# [*service_project_name*]
|
|
|
|
# (Optional) The service project name.
|
|
|
|
# Defaults to 'services'
|
|
|
|
#
|
|
|
|
# [*role_name*]
|
|
|
|
# (Optional) The role name.
|
|
|
|
# Defaults to 'admin'
|
|
|
|
#
|
|
|
|
# [*service_name*]
|
|
|
|
# (Optional) The service name.
|
|
|
|
# Defaults to 'keystone'
|
|
|
|
#
|
|
|
|
# [*admin_url*]
|
|
|
|
# (Optional) Admin URL for Keystone endpoint.
|
|
|
|
# This url should *not* contain any version or trailing '/'.
|
|
|
|
# Defaults to 'http://127.0.0.1:5000'
|
|
|
|
#
|
|
|
|
# [*public_url*]
|
|
|
|
# (Optional) Public URL for Keystone endpoint.
|
|
|
|
# This URL should *not* contain any version or trailing '/'.
|
|
|
|
# Defaults to 'http://127.0.0.1:5000'
|
|
|
|
#
|
|
|
|
# [*internal_url*]
|
|
|
|
# (Optional) Internal URL for Keystone endpoint.
|
|
|
|
# This URL should *not* contain any version or trailing '/'.
|
|
|
|
# Defaults to $public_url
|
|
|
|
#
|
|
|
|
# [*region*]
|
|
|
|
# (Optional) Region for endpoint.
|
|
|
|
# Defaults to 'RegionOne'
|
|
|
|
#
|
|
|
|
# [*interface*]
|
|
|
|
# (Optional) Which interface endpoint should be used.
|
|
|
|
# Defaults to 'public'
|
|
|
|
#
|
|
|
|
class keystone::bootstrap (
|
2020-06-18 16:32:12 +02:00
|
|
|
$password,
|
2019-11-02 12:32:24 +01:00
|
|
|
$username = 'admin',
|
|
|
|
$email = 'admin@localhost',
|
|
|
|
$project_name = 'admin',
|
|
|
|
$service_project_name = 'services',
|
|
|
|
$role_name = 'admin',
|
|
|
|
$service_name = 'keystone',
|
|
|
|
$admin_url = 'http://127.0.0.1:5000',
|
|
|
|
$public_url = 'http://127.0.0.1:5000',
|
|
|
|
$internal_url = undef,
|
|
|
|
$region = 'RegionOne',
|
|
|
|
$interface = 'public',
|
|
|
|
) inherits keystone::params {
|
|
|
|
|
2020-07-09 15:58:11 +09:00
|
|
|
include keystone::deps
|
2019-11-02 12:32:24 +01:00
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
$internal_url_real = $internal_url ? {
|
|
|
|
undef => $public_url,
|
|
|
|
default => $internal_url
|
2019-11-02 12:32:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if defined('$::keystone::keystone_user') {
|
|
|
|
$keystone_user = $::keystone::keystone_user
|
|
|
|
} else {
|
|
|
|
$keystone_user = $::keystone::params::keystone_user
|
|
|
|
}
|
|
|
|
|
|
|
|
# The initial bootstrap that creates all resources required but
|
|
|
|
# only subscribes to notifies from the keystone::dbsync::end anchor
|
|
|
|
# which means this is not guaranteed to execute on each run.
|
|
|
|
exec { 'keystone bootstrap':
|
|
|
|
command => 'keystone-manage bootstrap',
|
|
|
|
environment => [
|
2020-06-18 16:32:12 +02:00
|
|
|
"OS_BOOTSTRAP_USERNAME=${username}",
|
|
|
|
"OS_BOOTSTRAP_PASSWORD=${password}",
|
|
|
|
"OS_BOOTSTRAP_PROJECT_NAME=${project_name}",
|
|
|
|
"OS_BOOTSTRAP_ROLE_NAME=${role_name}",
|
2019-11-02 12:32:24 +01:00
|
|
|
"OS_BOOTSTRAP_SERVICE_NAME=${service_name}",
|
2020-06-18 16:32:12 +02:00
|
|
|
"OS_BOOTSTRAP_ADMIN_URL=${admin_url}",
|
|
|
|
"OS_BOOTSTRAP_PUBLIC_URL=${public_url}",
|
2019-11-02 12:32:24 +01:00
|
|
|
"OS_BOOTSTRAP_INTERNAL_URL=${internal_url_real}",
|
2020-06-18 16:32:12 +02:00
|
|
|
"OS_BOOTSTRAP_REGION_ID=${region}",
|
2019-11-02 12:32:24 +01:00
|
|
|
],
|
|
|
|
user => $keystone_user,
|
|
|
|
path => '/usr/bin',
|
|
|
|
refreshonly => true,
|
|
|
|
subscribe => Anchor['keystone::dbsync::end'],
|
|
|
|
notify => Anchor['keystone::service::begin'],
|
|
|
|
tag => 'keystone-bootstrap',
|
|
|
|
}
|
|
|
|
|
|
|
|
# Since the bootstrap is not guaranteed to execute on each run we
|
|
|
|
# use the below resources to make sure the current resources are
|
|
|
|
# correct so if some value was updated we set that.
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_role', $role_name, {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
|
|
|
})
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_user', $username, {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
|
|
|
'enabled' => true,
|
2020-06-18 16:32:12 +02:00
|
|
|
'email' => $email,
|
|
|
|
'password' => $password,
|
2019-11-02 12:32:24 +01:00
|
|
|
})
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_tenant', $service_project_name, {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
|
|
|
'enabled' => true,
|
|
|
|
})
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_tenant', $project_name, {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
|
|
|
'enabled' => true,
|
|
|
|
})
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_user_role', "${username}@${project_name}", {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
2020-06-18 16:32:12 +02:00
|
|
|
'roles' => $role_name,
|
2019-11-02 12:32:24 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
ensure_resource('keystone_service', "${service_name}::identity", {
|
|
|
|
'ensure' => 'present',
|
|
|
|
})
|
|
|
|
|
2020-06-18 16:32:12 +02:00
|
|
|
ensure_resource('keystone_endpoint', "${region}/${service_name}::identity", {
|
2019-11-02 12:32:24 +01:00
|
|
|
'ensure' => 'present',
|
2020-06-18 16:32:12 +02:00
|
|
|
'public_url' => $public_url,
|
|
|
|
'admin_url' => $admin_url,
|
2019-11-02 12:32:24 +01:00
|
|
|
'internal_url' => $internal_url_real,
|
|
|
|
})
|
|
|
|
|
|
|
|
# The below creates and populates the /etc/keystone/puppet.conf file that contains
|
|
|
|
# the credentials that can be loaded by providers. Ensure it has the proper owner,
|
|
|
|
# group and mode so that it cannot be read by anything other than root.
|
|
|
|
file { '/etc/keystone/puppet.conf':
|
|
|
|
ensure => 'present',
|
|
|
|
replace => false,
|
|
|
|
content => '',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0600',
|
|
|
|
require => Anchor['keystone::install::end'],
|
|
|
|
}
|
|
|
|
|
|
|
|
if $interface == 'admin' {
|
2020-06-18 16:32:12 +02:00
|
|
|
$auth_url_real = $admin_url
|
2019-11-02 12:32:24 +01:00
|
|
|
} elsif $interface == 'internal' {
|
|
|
|
$auth_url_real = $internal_url_real
|
|
|
|
} else {
|
2020-06-18 16:32:12 +02:00
|
|
|
$auth_url_real = $public_url
|
2019-11-02 12:32:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
keystone::resource::authtoken { 'keystone_puppet_config':
|
2020-06-18 16:32:12 +02:00
|
|
|
username => $username,
|
|
|
|
password => $password,
|
2019-11-02 12:32:24 +01:00
|
|
|
auth_url => $auth_url_real,
|
2020-06-18 16:32:12 +02:00
|
|
|
project_name => $project_name,
|
|
|
|
region_name => $region,
|
2019-11-02 12:32:24 +01:00
|
|
|
interface => $interface,
|
|
|
|
}
|
|
|
|
}
|