Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.

Commit 27227f7

Browse files
committed
Add Keystone
1 parent 07ea427 commit 27227f7

File tree

9 files changed

+205
-0
lines changed

9 files changed

+205
-0
lines changed

manifests/api/keystone.pp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class kickstack::api::keystone inherits kickstack {
2+
# Grab the Keystone admin token from a kickstack fact and configure
3+
# Keystone accordingly. If no fact has been set, generate a password.
4+
$admin_token = pick(getvar("${fact_prefix}keystone_admin_token"),pwgen())
5+
6+
class { '::keystone':
7+
package_ensure => 'latest',
8+
verbose => 'True',
9+
catalog_type => 'sql',
10+
admin_token => $admin_token,
11+
sql_connection => getvar("${fact_prefix}keystone_sql_connection"),
12+
}
13+
14+
kickstack::exportfact::export { "keystone_admin_token":
15+
value => "${admin_token}",
16+
tag => "keystone",
17+
require => Class['::keystone']
18+
}
19+
20+
# Installs the service user endpoint.
21+
class { '::keystone::endpoint':
22+
public_address => "${hostname}${keystone_public_suffix}",
23+
admin_address => "${hostname}${keystone_admin_suffix}",
24+
internal_address => $hostname,
25+
region => $keystone_region,
26+
require => Class['::keystone']
27+
}
28+
29+
kickstack::exportfact::export { "keystone_internal_address":
30+
value => "${hostname}",
31+
tag => "keystone",
32+
require => Class['::keystone::endpoint']
33+
}
34+
35+
# Adds the admin credential to keystone.
36+
class { '::keystone::roles::admin':
37+
email => $keystone_admin_email,
38+
password => $keystone_admin_password,
39+
admin_tenant => $keystone_admin_tenant,
40+
service_tenant => $keystone_service_tenant,
41+
require => Class['::keystone::endpoint']
42+
}
43+
}

manifests/apinode.pp

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class kickstack::apinode inherits kickstack {
2+
include kickstack::api::keystone
3+
}

manifests/cloudcontroller.pp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class kickstack::cloudcontroller inherits kickstack {
2+
3+
include kickstack::rpc
4+
include kickstack::db
5+
6+
kickstack::db::service { ['keystone','glance','cinder','nova']: }
7+
8+
}

manifests/db.pp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class kickstack::db inherits kickstack {
2+
3+
case $database {
4+
'mysql': {
5+
$mysql_service = 'mysql'
6+
ensure_resource('class',
7+
'mysql::server',
8+
{ config_hash => {
9+
'root_password' => "$mysql_root_password",
10+
'bind_address' => "0.0.0.0"
11+
}})
12+
ensure_resource('file',
13+
'/etc/mysql/conf.d/skip-name-resolve.cnf',
14+
{ source => "puppet:///modules/kickstack/mysql/skip-name-resolve.cnf",
15+
})
16+
}
17+
'postgresql': {
18+
ensure_resource('class',
19+
'postgresql::server',
20+
{ config_hash => {
21+
'ip_mask_deny_postgres_user' => '0.0.0.0/32',
22+
'ip_mask_allow_all_users' => '0.0.0.0/0',
23+
'listen_addresses' => '*',
24+
'postgres_password' => "$postgres_password"}})
25+
}
26+
}
27+
28+
}
29+

manifests/db/service.pp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
define kickstack::db::service {
2+
3+
include pwgen
4+
5+
$fact_prefix = $::kickstack::fact_prefix
6+
$database = $::kickstack::database
7+
8+
$servicename = $name
9+
$username = $name
10+
11+
# Retrieve the currently set password for the service from its
12+
# kickstack_*_sql_connection fact.
13+
# If it's unset, generate one and subsequently export it.
14+
$sql_connection = getvar("${fact_prefix}${servicename}_sql_connection")
15+
$sql_password = $sql_connection ? {
16+
undef => pwgen(),
17+
default => pick(regsubst(getvar("${fact_prefix}${servicename}_sql_connection"),
18+
".*://${username}:(.*)@.*/${servicename}",
19+
'\1'),
20+
pwgen())
21+
}
22+
23+
# Export facts about the database only after configuring the database
24+
Class["${servicename}::db::${database}"] -> Exportfact::Export<| tag == "$database" |>
25+
26+
# Configure the service database (classes look like nova::db::mysql or
27+
# glance::db:postgresql, for example).
28+
# If running on mysql, set the "allowed_hosts" parameter to % so we
29+
# can connect to the database from anywhere.
30+
case "${database}" {
31+
"mysql": {
32+
class { "${servicename}::db::mysql":
33+
user => "$username",
34+
password => "$sql_password",
35+
charset => "utf8",
36+
allowed_hosts => '%'
37+
}
38+
}
39+
default: {
40+
class { "${name}::db::${database}":
41+
password => "$sql_password"
42+
}
43+
}
44+
}
45+
46+
# Export the MySQL connection string for the service
47+
kickstack::exportfact::export { "${name}_sql_connection":
48+
value => "${database}://${name}:${sql_password}@${hostname}/${name}",
49+
tag => "$database"
50+
}
51+
52+
}

manifests/exportfact/export.pp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
define kickstack::exportfact::export (
2+
$value
3+
) {
4+
5+
::exportfact::export { "${kickstack::fact_prefix}${name}":
6+
value => $value,
7+
category => "$kickstack::fact_category"
8+
}
9+
10+
}

manifests/init.pp

+8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
$rabbit_user = $kickstack::params::rabbit_user,
2424
$rabbit_virtual_host = $kickstack::params::rabbit_virtual_host,
2525
$qpid_username = $kickstack::params::qpid_username,
26+
$keystone_region = $kickstack::params::keystone_region,
27+
$keystone_public_suffix = $kickstack::params::keystone_public_suffix,
28+
$keystone_admin_suffix = $kickstack::params::keystone_admin_suffix,
29+
$keystone_admin_tenant = $kickstack::params::keystone_admin_tenant,
30+
$keystone_service_tenant = $kickstack::params::keystone_service_tenant,
31+
$keystone_admin_email = $kickstack::params::keystone_admin_email,
32+
$keystone_admin_password = $kickstack::params::keystone_admin_password,
2633
) inherits kickstack::params {
2734

2835
include exportfact
36+
include openstack::repo
2937
}

manifests/params.pp

+24
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,28 @@
4949
# Qpid password:
5050
$qpid_password = getvar("::${variable_prefix}qpid_password")
5151

52+
# The Keystone region to manage
53+
$keystone_region = pick(getvar("::${variable_prefix}keystone_region"), 'kickstack')
54+
55+
# The suffix to append to the keystone hostname for publishing
56+
# the public service endpoint
57+
$keystone_public_suffix = getvar("::${variable_prefix}keystone_public_suffix")
58+
59+
# The suffix to append to the keystone hostname for publishing
60+
# the admin service endpoint
61+
$keystone_admin_suffix = getvar("::${variable_prefix}keystone_admin_suffix")
62+
63+
# The tenant set up so that individual OpenStack services can
64+
# authenticate with Keystone
65+
$keystone_service_tenant = getvar("::${variable_prefix}keystone_service_tenant")
66+
67+
# The special tenant set up for administrative purposes
68+
$keystone_admin_tenant = getvar("::${variable_prefix}keystone_admin_tenant")
69+
70+
# The email address set for the admin user
71+
$keystone_admin_email = pick(getvar("::${variable_prefix}keystone_admin_email"),"admin@${hostname}")
72+
73+
# The initial password to set for the admin user
74+
$keystone_admin_password = pick(getvar("::${variable_prefix}keystone_admin_password"),"kickstack")
75+
5276
}

manifests/rpc.pp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class kickstack::rpc inherits kickstack {
2+
case "$rpc" {
3+
'rabbitmq': {
4+
Class['nova::rabbitmq'] -> Exportfact::Export<| tag == 'rabbit' |>
5+
6+
class { 'nova::rabbitmq': }
7+
8+
kickstack::exportfact::export { "rabbit_host":
9+
value => "$hostname",
10+
tag => "rabbit"
11+
}
12+
13+
}
14+
'qpid': {
15+
Class['nova::qpid'] -> Exportfact::Export<| tag == 'qpid' |>
16+
17+
class { 'nova::qpid': }
18+
19+
kickstack::exportfact::export { "qpid_hostname":
20+
value => "$hostname",
21+
tag => "qpid"
22+
}
23+
}
24+
default: {
25+
warn("Unsupported RPC server type: ${rpc_server}")
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)