From 530f7f1f9053cbbf03a241f1865c388a529aacb1 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Wed, 2 Jul 2014 18:22:35 +0200 Subject: [PATCH 01/11] trove: manage MySQL trove database - OpenStack Trove database - add the puppet-trove module in fixtures Signed-off-by: Emilien Macchi --- .fixtures.yml | 2 ++ manifests/database/sql.pp | 12 ++++++++++++ spec/classes/cloud_database_sql_spec.rb | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index a6589ee6..ac475a5f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -27,6 +27,8 @@ fixtures: 'heat': repo: 'git://github.com/enovance/puppet-heat' ref: '025b8cb830d7fa476c4ab1a0b0228b88b5ba10c3' + 'trove': + repo: 'git://github.com/enovance/puppet-trove' 'apt': repo: 'git://github.com/enovance/puppetlabs-apt.git' ref: '9b001af8775c7231ea2656b7eb43d6141b536f49' diff --git a/manifests/database/sql.pp b/manifests/database/sql.pp index d8d20777..de5b1acd 100644 --- a/manifests/database/sql.pp +++ b/manifests/database/sql.pp @@ -51,6 +51,10 @@ class cloud::database::sql ( $neutron_db_user = 'neutron', $neutron_db_password = 'neutronpassword', $neutron_db_allowed_hosts = ['127.0.0.1'], + $trove_db_host = '127.0.0.1', + $trove_db_user = 'trove', + $trove_db_password = 'trovepassword', + $trove_db_allowed_hosts = ['127.0.0.1'], $mysql_root_password = 'rootpassword', $mysql_sys_maint_password = 'sys_maint', $galera_clustercheck_dbuser = 'clustercheckdbuser', @@ -208,6 +212,14 @@ class cloud::database::sql ( allowed_hosts => $heat_db_allowed_hosts, } + class { 'trove::db::mysql': + dbname => 'trove', + user => $trove_db_user, + password => $trove_db_password, + host => $trove_db_host, + allowed_hosts => $trove_db_allowed_hosts, + } + # Monitoring DB warning('Database mapping must be updated to puppetlabs/puppetlabs-mysql >= 2.x (see: https://dev.ring.enovance.com/redmine/issues/4510)') diff --git a/spec/classes/cloud_database_sql_spec.rb b/spec/classes/cloud_database_sql_spec.rb index 704f4524..c6071495 100644 --- a/spec/classes/cloud_database_sql_spec.rb +++ b/spec/classes/cloud_database_sql_spec.rb @@ -56,6 +56,10 @@ describe 'cloud::database::sql' do :neutron_db_user => 'neutron', :neutron_db_password => 'secrete', :neutron_db_allowed_hosts => ['10.0.0.1','10.0.0.2','10.0.0.3'], + :trove_db_host => '10.0.0.1', + :trove_db_user => 'trove', + :trove_db_password => 'secrete', + :trove_db_allowed_hosts => ['10.0.0.1','10.0.0.2','10.0.0.3'], :mysql_root_password => 'secrete', :mysql_sys_maint_password => 'sys', :galera_clustercheck_dbuser => 'clustercheckuser', @@ -152,6 +156,15 @@ describe 'cloud::database::sql' do :allowed_hosts => ['10.0.0.1','10.0.0.2','10.0.0.3'] ) end + it 'configure trove database' do + should contain_class('trove::db::mysql').with( + :dbname => 'trove', + :user => 'trove', + :password => 'secrete', + :host => '10.0.0.1', + :allowed_hosts => ['10.0.0.1','10.0.0.2','10.0.0.3'] ) + end + it 'configure monitoring database' do should contain_database('monitoring').with( :ensure => 'present', From 3bf68c72378ceb167ba062af119185ac0c8c3822 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 3 Jul 2014 00:10:22 +0200 Subject: [PATCH 02/11] trove: manage keystone resources Manage endpoint, tenant, user and password for Trove service. Signed-off-by: Emilien Macchi --- manifests/identity.pp | 52 +++++++++++++++++++++++++++++ spec/classes/cloud_identity_spec.rb | 22 ++++++++++++ 2 files changed, 74 insertions(+) diff --git a/manifests/identity.pp b/manifests/identity.pp index 88a638fe..ee1870db 100644 --- a/manifests/identity.pp +++ b/manifests/identity.pp @@ -110,6 +110,18 @@ # (optional) Public Hostname or IP to connect to Cinder API # Defaults to '127.0.0.1' # +# [*ks_trove_internal_host*] +# (optional) Internal Hostname or IP to connect to Trove API +# Defaults to '127.0.0.1' +# +# [*ks_trove_admin_host*] +# (optional) Admin Hostname or IP to connect to Trove API +# Defaults to '127.0.0.1' +# +# [*ks_trove_public_host*] +# (optional) Public Hostname or IP to connect to Trove API +# Defaults to '127.0.0.1' +# # [*ks_neutron_internal_host*] # (optional) Internal Hostname or IP to connect to Neutron API # Defaults to '127.0.0.1' @@ -146,6 +158,10 @@ # (optional) Public Hostname or IP to connect to Swift API # Defaults to '127.0.0.1' # +# [*ks_trove_password*] +# (optional) Password used by Trove to connect to Keystone API +# Defaults to 'trovepassword' +# # [*ks_ceilometer_password*] # (optional) Password used by Ceilometer to connect to Keystone API # Defaults to 'ceilometerpassword' @@ -194,6 +210,10 @@ # (optional) Protocol used to connect to API. Could be 'http' or 'https'. # Defaults to 'http' # +# [*ks_trove_public_proto*] +# (optional) Protocol used to connect to API. Could be 'http' or 'https'. +# Defaults to 'http' +# # [*ks_glance_public_proto*] # (optional) Protocol used to connect to API. Could be 'http' or 'https'. # Defaults to 'http' @@ -234,6 +254,18 @@ # (optional) TCP port to connect to Nova API from internal network # Defaults to '8774' # +# [*ks_trove_internal_port*] +# (optional) TCP port to connect to Trove API from internal network +# Defaults to '8779' +# +# [*ks_trove_public_port*] +# (optional) TCP port to connect to Trove API from public network +# Defaults to '8779' +# +# [*ks_trove_admin_port*] +# (optional) TCP port to connect to Trove API from admin network +# Defaults to '8779' +# # [*ks_nova_public_port*] # (optional) TCP port to connect to Nova API from public network # Defaults to '8774' @@ -398,6 +430,14 @@ class cloud::identity ( $ks_swift_public_proto = 'http', $ks_swift_admin_proto = 'http', $ks_swift_internal_proto = 'http', + $ks_trove_admin_host = '127.0.0.1', + $ks_trove_internal_host = '127.0.0.1', + $ks_trove_password = 'trovepassword', + $ks_trove_public_host = '127.0.0.1', + $ks_trove_public_port = 8779, + $ks_trove_public_proto = 'http', + $ks_trove_admin_proto = 'http', + $ks_trove_internal_proto = 'http', $api_eth = '127.0.0.1', $region = 'RegionOne', $verbose = true, @@ -577,6 +617,18 @@ class cloud::identity ( password => $ks_heat_password } + class {'trove::keystone::auth': + admin_address => $ks_trove_admin_host, + internal_address => $ks_trove_internal_host, + public_address => $ks_trove_public_host, + public_protocol => $ks_trove_public_proto, + admin_protocol => $ks_trove_admin_proto, + internal_protocol => $ks_trove_internal_proto, + port => $ks_trove_public_port, + region => $region, + password => $ks_trove_password + } + # Purge expored tokens every days at midnight class { 'keystone::cron::token_flush': } diff --git a/spec/classes/cloud_identity_spec.rb b/spec/classes/cloud_identity_spec.rb index 5ffddf39..bcd164c0 100644 --- a/spec/classes/cloud_identity_spec.rb +++ b/spec/classes/cloud_identity_spec.rb @@ -98,6 +98,14 @@ describe 'cloud::identity' do :ks_swift_admin_proto => 'https', :ks_swift_internal_proto => 'https', :ks_swift_admin_host => '10.0.0.1', + :ks_trove_admin_host => '10.0.0.1', + :ks_trove_internal_host => '10.0.0.1', + :ks_trove_password => 'secrete', + :ks_trove_public_host => '10.0.0.1', + :ks_trove_public_port => '8779', + :ks_trove_public_proto => 'https', + :ks_trove_admin_proto => 'https', + :ks_trove_internal_proto => 'https', :region => 'BigCloud', :verbose => true, :debug => true, @@ -203,6 +211,20 @@ describe 'cloud::identity' do ) end + it 'configure trove endpoints' do + should contain_class('trove::keystone::auth').with( + :admin_address => '10.0.0.1', + :internal_address => '10.0.0.1', + :password => 'secrete', + :port => '8779', + :public_address => '10.0.0.1', + :public_protocol => 'https', + :admin_protocol => 'https', + :internal_protocol => 'https', + :region => 'BigCloud' + ) + end + it 'configure nova endpoints' do should contain_class('nova::keystone::auth').with( :admin_address => '10.0.0.1', From 37ffc88e071ddfb082b160a69b09ff486be95f55 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 3 Jul 2014 00:15:02 +0200 Subject: [PATCH 03/11] trove: add API binding in HAproxy As an option, bring support of Trove API binding in HAproxy configuration. Note: there is no unit tests, since we already cover this code. Signed-off-by: Emilien Macchi --- manifests/loadbalancer.pp | 15 +++++++++++++++ spec/classes/cloud_loadbalancer_spec.rb | 3 +++ 2 files changed, 18 insertions(+) diff --git a/manifests/loadbalancer.pp b/manifests/loadbalancer.pp index b64b9fae..78732a51 100644 --- a/manifests/loadbalancer.pp +++ b/manifests/loadbalancer.pp @@ -119,6 +119,13 @@ # If set to false, no binding will be configure # Defaults to true # +# [*trive_api*] +# (optional) Enable or not Trove public binding. +# If true, both public and internal will attempt to be created except if vip_internal_ip is set to false (backward compatibility). +# If set to ['10.0.0.1'], only IP in the array (or in the string) will be configured in the pool. They must be part of keepalived_ip options. +# If set to false, no binding will be configure +# Defaults to true +# # [*ec2_api*] # (optional) Enable or not EC2 public binding. # If true, both public and internal will attempt to be created except if vip_internal_ip is set to false (backward compatibility). @@ -171,6 +178,7 @@ class cloud::loadbalancer( $metadata_api = true, $keystone_api = true, $keystone_api_admin = true, + $trove_api = true, $horizon = true, $spice = true, $haproxy_auth = 'admin:changeme', @@ -193,6 +201,7 @@ class cloud::loadbalancer( $metadata_bind_options = [], $neutron_bind_options = [], $nova_bind_options = [], + $trove_bind_options = [], $swift_bind_options = [], $spice_bind_options = [], $horizon_bind_options = [], @@ -211,6 +220,7 @@ class cloud::loadbalancer( $ks_neutron_public_port = 9696, $ks_nova_public_port = 8774, $ks_swift_public_port = 8080, + $ks_trove_public_port = 8779, $horizon_port = 80, $spice_port = 6082, $vip_public_ip = ['127.0.0.1'], @@ -369,6 +379,11 @@ class cloud::loadbalancer( bind_options => $spice_bind_options, httpchk => 'httpchk GET /'; } + cloud::loadbalancer::binding { 'trove_api_cluster': + ip => $trove_api, + port => $ks_trove_public_port, + bind_options => $trove_bind_options, + } cloud::loadbalancer::binding { 'glance_api_cluster': ip => $glance_api, options => { diff --git a/spec/classes/cloud_loadbalancer_spec.rb b/spec/classes/cloud_loadbalancer_spec.rb index a6bce617..d2b48161 100644 --- a/spec/classes/cloud_loadbalancer_spec.rb +++ b/spec/classes/cloud_loadbalancer_spec.rb @@ -36,6 +36,7 @@ describe 'cloud::loadbalancer' do :swift_api => true, :keystone_api_admin => true, :keystone_api => true, + :trove_api => true, :horizon => true, :spice => true, :ceilometer_bind_options => [], @@ -50,6 +51,7 @@ describe 'cloud::loadbalancer' do :keystone_admin_bind_options => [], :metadata_bind_options => [], :neutron_bind_options => [], + :trove_bind_options => [], :swift_bind_options => [], :spice_bind_options => [], :horizon_bind_options => [], @@ -76,6 +78,7 @@ describe 'cloud::loadbalancer' do :ks_keystone_admin_port => '35357', :ks_cinder_public_port => '8776', :ks_neutron_public_port => '9696', + :ks_trove_public_port => '8779', :ks_heat_public_port => '8004', :ks_heat_cfn_public_port => '8000', :ks_heat_cloudwatch_public_port => '8003' } From 0db2269b3638681fd706d5b040fd227606275806 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 3 Jul 2014 13:54:41 +0200 Subject: [PATCH 04/11] Implement cloud::database::dbaas This class will be the common things to have when running Database as a Service (Trove). Signed-off-by: Emilien Macchi --- manifests/database/dbaas.pp | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 manifests/database/dbaas.pp diff --git a/manifests/database/dbaas.pp b/manifests/database/dbaas.pp new file mode 100644 index 00000000..334df315 --- /dev/null +++ b/manifests/database/dbaas.pp @@ -0,0 +1,85 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: cloud::database::dbaas +# +# Common class to install OpenStack Database as a Service (Trove) +# +# === Parameters: +# +# [*trove_db_host*] +# (optional) Hostname or IP address to connect to trove database +# Defaults to '127.0.0.1' +# +# [*trove_db_user*] +# (optional) Username to connect to trove database +# Defaults to 'trove' +# +# [*trove_db_password*] +# (optional) Password to connect to trove database +# Defaults to 'trovepassword' +# +# [*rabbit_hosts*] +# (optional) List of RabbitMQ servers. Should be an array. +# Defaults to ['127.0.0.1:5672'] +# +# [*rabbit_password*] +# (optional) Password to connect to nova queues. +# Defaults to 'rabbitpassword' +# +# [*nova_proxy_admin_user*] +# (optional) Admin username used to connect to nova. +# Defaults to 'admin' +# +# [*nova_proxy_admin_pass*] +# (optional) Admin password used to connect to nova. +# Defaults to 'trovepassword' +# +# [*nova_proxy_admin_tenant_name*] +# (optional) Admin tenant name used to connect to nova. +# Defaults to 'admin' +# + +class cloud::database::dbaas( + $trove_db_host = '127.0.0.1', + $trove_db_user = 'trove', + $trove_db_password = 'trovepassword', + $rabbit_hosts = ['127.0.0.1:5672'], + $rabbit_password = 'rabbitpassword', + $nova_proxy_admin_pass = 'novapassword', + $nova_proxy_admin_user = 'admin', + $nova_proxy_admin_tenant_name = 'admin', +) { + + $encoded_user = uriescape($trove_db_user) + $encoded_password = uriescape($trove_db_password) + + class { 'trove': + database_connection => "mysql://${encoded_user}:${encoded_password}@${trove_db_host}/trove?charset=utf8", + rabbit_hosts => $rabbit_hosts, + rabbit_password => $rabbit_password, + nova_proxy_admin_pass => $nova_proxy_admin_pass, + nova_proxy_admin_user => $nova_proxy_admin_user, + nova_proxy_admin_tenant_name => $nova_proxy_admin_tenant_name + } + + exec {'trove_db_sync': + command => 'trove-manage db sync', + user => 'trove', + path => '/usr/bin', + unless => "/usr/bin/mysql trove -h ${trove_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } + +} From 7c4ca93b1906c74fd0e2d716a7ea1caa86efc23f Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 3 Jul 2014 18:16:29 +0200 Subject: [PATCH 05/11] trove: implement API, Conductor and Taskmanager Implement all the class we need on controller nodes. Signed-off-by: Emilien Macchi --- manifests/database/dbaas.pp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/manifests/database/dbaas.pp b/manifests/database/dbaas.pp index 334df315..c12e8094 100644 --- a/manifests/database/dbaas.pp +++ b/manifests/database/dbaas.pp @@ -58,9 +58,9 @@ class cloud::database::dbaas( $trove_db_password = 'trovepassword', $rabbit_hosts = ['127.0.0.1:5672'], $rabbit_password = 'rabbitpassword', - $nova_proxy_admin_pass = 'novapassword', - $nova_proxy_admin_user = 'admin', - $nova_proxy_admin_tenant_name = 'admin', + $nova_admin_username = 'trove', + $nova_admin_tenant_name = 'services', + $nova_admin_password = 'trovepassword', ) { $encoded_user = uriescape($trove_db_user) @@ -70,9 +70,10 @@ class cloud::database::dbaas( database_connection => "mysql://${encoded_user}:${encoded_password}@${trove_db_host}/trove?charset=utf8", rabbit_hosts => $rabbit_hosts, rabbit_password => $rabbit_password, - nova_proxy_admin_pass => $nova_proxy_admin_pass, - nova_proxy_admin_user => $nova_proxy_admin_user, - nova_proxy_admin_tenant_name => $nova_proxy_admin_tenant_name + rabbit_userid => 'trove', + nova_proxy_admin_pass => $nova_admin_password, + nova_proxy_admin_user => $nova_admin_username, + nova_proxy_admin_tenant_name => $nova_admin_tenant_name } exec {'trove_db_sync': From c2a462d4897ff71db7bc3352f2c60feae8c4d1b3 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 3 Jul 2014 22:56:32 +0200 Subject: [PATCH 06/11] Puppetfile: add puppet-trove module Signed-off-by: Emilien Macchi --- Puppetfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Puppetfile b/Puppetfile index 7a4a8d8b..3a4c02ff 100644 --- a/Puppetfile +++ b/Puppetfile @@ -45,6 +45,9 @@ mod 'swift', :git => 'git://github.com/enovance/puppet-swift.git', :ref => 'f7d1385d6990492705ddaa228ffa544ca235913a' +mod 'trove', + :git => 'git://github.com/enovance/puppet-trove.git' + # Dependency mod 'apache', :git => 'git://github.com/enovance/puppetlabs-apache.git', From d6b637afad88de60f0c74e4522663fcb5d0d4fa3 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 4 Jul 2014 00:14:13 +0200 Subject: [PATCH 07/11] messaging: add trove user & queue in RabbitMQ Signed-off-by: Emilien Macchi --- manifests/messaging.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/messaging.pp b/manifests/messaging.pp index db1a21d9..1414397d 100644 --- a/manifests/messaging.pp +++ b/manifests/messaging.pp @@ -66,7 +66,7 @@ class cloud::messaging( provider => 'rabbitmqctl', require => Class['rabbitmq'], } - rabbitmq_user { ['nova','glance','neutron','cinder','ceilometer','heat']: + rabbitmq_user { ['nova','glance','neutron','cinder','ceilometer','heat','trove']: admin => true, password => $rabbit_password, provider => 'rabbitmqctl', @@ -79,6 +79,7 @@ class cloud::messaging( 'cinder@/', 'ceilometer@/', 'heat@/', + 'trove@/', ]: configure_permission => '.*', write_permission => '.*', From 1f86669a4c4d4e0875a2e0095da85b9b1cc1a81e Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 4 Jul 2014 08:40:28 +0200 Subject: [PATCH 08/11] trove/lb: fix a typo in doc Signed-off-by: Emilien Macchi --- manifests/loadbalancer.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/loadbalancer.pp b/manifests/loadbalancer.pp index 78732a51..3c6768d6 100644 --- a/manifests/loadbalancer.pp +++ b/manifests/loadbalancer.pp @@ -119,7 +119,7 @@ # If set to false, no binding will be configure # Defaults to true # -# [*trive_api*] +# [*trove_api*] # (optional) Enable or not Trove public binding. # If true, both public and internal will attempt to be created except if vip_internal_ip is set to false (backward compatibility). # If set to ['10.0.0.1'], only IP in the array (or in the string) will be configured in the pool. They must be part of keepalived_ip options. From 7eb5a16a1c8e7517e61f1b940158f27d70b76e3d Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 4 Jul 2014 10:07:54 +0200 Subject: [PATCH 09/11] pin last commit of puppet-trove --- .fixtures.yml | 1 + Puppetfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index ac475a5f..877c2e90 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -29,6 +29,7 @@ fixtures: ref: '025b8cb830d7fa476c4ab1a0b0228b88b5ba10c3' 'trove': repo: 'git://github.com/enovance/puppet-trove' + ref: '6cad2a1474ece5dad813821893f994b69df29fed' 'apt': repo: 'git://github.com/enovance/puppetlabs-apt.git' ref: '9b001af8775c7231ea2656b7eb43d6141b536f49' diff --git a/Puppetfile b/Puppetfile index 3a4c02ff..66d1c2bd 100644 --- a/Puppetfile +++ b/Puppetfile @@ -44,9 +44,9 @@ mod 'nova', mod 'swift', :git => 'git://github.com/enovance/puppet-swift.git', :ref => 'f7d1385d6990492705ddaa228ffa544ca235913a' - mod 'trove', :git => 'git://github.com/enovance/puppet-trove.git' + :ref => '6cad2a1474ece5dad813821893f994b69df29fed' # Dependency mod 'apache', From e3d787829c236e75768427951e1d53c5051956db Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 4 Jul 2014 14:30:43 +0200 Subject: [PATCH 10/11] HAproxy/monitor: add Trove --- templates/loadbalancer/monitor.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/loadbalancer/monitor.erb b/templates/loadbalancer/monitor.erb index cfc46780..e8749deb 100644 --- a/templates/loadbalancer/monitor.erb +++ b/templates/loadbalancer/monitor.erb @@ -66,6 +66,10 @@ monitor fail if heat_cloudwatch_api_dead acl horizon_dead nbsrv(horizon_cluster) lt 1 monitor fail if horizon_dead <%- end -%> +<%- if @trove_api -%> +acl trove_api_dead nbsrv(trove_api_cluster) lt 1 +monitor fail if trove_api_dead +<%- end -%> # Used when forwarding SSL in http headers acl is-ssl dst_port 443 From f955e8362a8ed18f6b863fc1f21e8cbd1eef0b48 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 4 Jul 2014 14:34:30 +0200 Subject: [PATCH 11/11] DBaaS: add API, conductor & taskmanager --- manifests/database/dbaas/api.pp | 53 ++++++++++ manifests/database/dbaas/conductor.pp | 39 ++++++++ manifests/database/dbaas/taskmanager.pp | 39 ++++++++ spec/classes/cloud_database_dbaas_api_spec.rb | 99 +++++++++++++++++++ .../cloud_database_dbaas_conductor_spec.rb | 85 ++++++++++++++++ .../cloud_database_dbaas_taskmanager_spec.rb | 85 ++++++++++++++++ 6 files changed, 400 insertions(+) create mode 100644 manifests/database/dbaas/api.pp create mode 100644 manifests/database/dbaas/conductor.pp create mode 100644 manifests/database/dbaas/taskmanager.pp create mode 100644 spec/classes/cloud_database_dbaas_api_spec.rb create mode 100644 spec/classes/cloud_database_dbaas_conductor_spec.rb create mode 100644 spec/classes/cloud_database_dbaas_taskmanager_spec.rb diff --git a/manifests/database/dbaas/api.pp b/manifests/database/dbaas/api.pp new file mode 100644 index 00000000..72234c7a --- /dev/null +++ b/manifests/database/dbaas/api.pp @@ -0,0 +1,53 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: cloud::database::dbaas::api +# +# Class to install API service of OpenStack Database as a Service (Trove) +# + +class cloud::database::dbaas::api( + $ks_trove_password = 'trovepassword', + $verbose = true, + $debug = true, + $use_syslog = true, + $api_eth = '127.0.0.1', + $ks_trove_public_port = '8779', + $ks_keystone_internal_host = '127.0.0.1', + $ks_keystone_internal_port = '5000', + $ks_keystone_internal_proto = 'http', +) { + + include 'cloud::database::dbaas' + + class { 'trove::api': + verbose => $verbose, + debug => $debug, + use_syslog => $use_syslog, + bind_host => $api_eth, + bind_port => $ks_trove_public_port, + auth_url => "${ks_keystone_internal_proto}://${ks_keystone_internal_host}:${ks_keystone_internal_port}/v2.0", + keystone_password => $ks_trove_password, + } + + @@haproxy::balancermember{"${::fqdn}-trove_api": + listening_service => 'trove_api_cluster', + server_names => $::hostname, + ipaddresses => $api_eth, + ports => $ks_trove_public_port, + options => 'check inter 2000 rise 2 fall 5' + } + +} diff --git a/manifests/database/dbaas/conductor.pp b/manifests/database/dbaas/conductor.pp new file mode 100644 index 00000000..9ef0903c --- /dev/null +++ b/manifests/database/dbaas/conductor.pp @@ -0,0 +1,39 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: cloud::database::dbaas::conductor +# +# Class to install Conductor service of OpenStack Database as a Service (Trove) +# + +class cloud::database::dbaas::conductor( + $ks_keystone_internal_host = '127.0.0.1', + $ks_keystone_internal_port = '5000', + $ks_keystone_internal_proto = 'http', + $verbose = true, + $debug = true, + $use_syslog = true, +) { + + include 'cloud::database::dbaas' + + class { 'trove::conductor': + auth_url => "${ks_keystone_internal_proto}://${ks_keystone_internal_host}:${ks_keystone_internal_port}/v2.0", + debug => $debug, + verbose => $verbose, + use_syslog => $use_syslog + } + +} diff --git a/manifests/database/dbaas/taskmanager.pp b/manifests/database/dbaas/taskmanager.pp new file mode 100644 index 00000000..4a7e6b03 --- /dev/null +++ b/manifests/database/dbaas/taskmanager.pp @@ -0,0 +1,39 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: cloud::database::dbaas::taskmanager +# +# Class to install Taskmanager service of OpenStack Database as a Service (Trove) +# + +class cloud::database::dbaas::taskmanager( + $ks_keystone_internal_host = '127.0.0.1', + $ks_keystone_internal_port = '5000', + $ks_keystone_internal_proto = 'http', + $debug = true, + $verbose = true, + $use_syslog = true +) { + + include 'cloud::database::dbaas' + + class { 'trove::taskmanager': + auth_url => "${ks_keystone_internal_proto}://${ks_keystone_internal_host}:${ks_keystone_internal_port}/v2.0", + debug => $debug, + verbose => $verbose, + use_syslog => $use_syslog + } + +} diff --git a/spec/classes/cloud_database_dbaas_api_spec.rb b/spec/classes/cloud_database_dbaas_api_spec.rb new file mode 100644 index 00000000..413853bb --- /dev/null +++ b/spec/classes/cloud_database_dbaas_api_spec.rb @@ -0,0 +1,99 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for cloud::database::dbaas::api class +# + +require 'spec_helper' + +describe 'cloud::database::dbaas::api' do + + shared_examples_for 'openstack database dbaas api' do + + let :pre_condition do + "class { 'cloud::database::dbaas': + trove_db_host => '10.0.0.1', + trove_db_user => 'trove', + trove_db_password => 'secrete', + nova_admin_username => 'trove', + nova_admin_password => 'trovepassword', + nova_admin_tenant_name => 'services', + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete' }" + end + + let :params do + { :ks_keystone_internal_host => '10.0.0.1', + :ks_keystone_internal_proto => 'https', + :ks_trove_password => 'trovepassword', + :api_eth => '10.0.0.1', + :debug => true, + :verbose => true, + :use_syslog => true, + :ks_trove_public_port => '8779' } + end + + it 'configure trove common' do + should contain_class('trove').with( + :rabbit_userid => 'trove', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :nova_proxy_admin_pass => 'trovepassword', + :nova_proxy_admin_user => 'trove', + :nova_proxy_admin_tenant_name => 'services', + :database_connection => 'mysql://trove:secrete@10.0.0.1/trove?charset=utf8', + ) + end + + it 'configure trove api' do + should contain_class('trove::api').with( + :verbose => true, + :debug => true, + :use_syslog => true, + :bind_host => '10.0.0.1', + :bind_port => '8779', + :auth_url => 'https://10.0.0.1:5000/v2.0', + :keystone_password => 'trovepassword' + ) + end + + it 'checks if Trove DB is populated' do + should contain_exec('trove_db_sync').with( + :command => 'trove-manage db sync', + :user => 'trove', + :path => '/usr/bin', + :unless => '/usr/bin/mysql trove -h 10.0.0.1 -u trove -psecrete -e "show tables" | /bin/grep Tables' + ) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack database dbaas api' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + it_configures 'openstack database dbaas api' + end + +end diff --git a/spec/classes/cloud_database_dbaas_conductor_spec.rb b/spec/classes/cloud_database_dbaas_conductor_spec.rb new file mode 100644 index 00000000..f47a1bb3 --- /dev/null +++ b/spec/classes/cloud_database_dbaas_conductor_spec.rb @@ -0,0 +1,85 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for cloud::database::dbaas::conductor class +# + +require 'spec_helper' + +describe 'cloud::database::dbaas::conductor' do + + shared_examples_for 'openstack database dbaas conductor' do + + let :pre_condition do + "class { 'cloud::database::dbaas': + trove_db_host => '10.0.0.1', + trove_db_user => 'trove', + trove_db_password => 'secrete', + nova_admin_username => 'trove', + nova_admin_password => 'trovepassword', + nova_admin_tenant_name => 'services', + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete' }" + end + + let :params do + { :ks_keystone_internal_host => '10.0.0.1', + :ks_keystone_internal_port => '5000', + :ks_keystone_internal_proto => 'https', + :debug => true, + :verbose => true, + :use_syslog => true } + end + + it 'configure trove common' do + should contain_class('trove').with( + :rabbit_userid => 'trove', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :nova_proxy_admin_pass => 'trovepassword', + :nova_proxy_admin_user => 'trove', + :nova_proxy_admin_tenant_name => 'services', + :database_connection => 'mysql://trove:secrete@10.0.0.1/trove?charset=utf8', + ) + end + + it 'configure trove conductor' do + should contain_class('trove::conductor').with( + :verbose => true, + :debug => true, + :use_syslog => true, + :auth_url => 'https://10.0.0.1:5000/v2.0', + ) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack database dbaas conductor' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + it_configures 'openstack database dbaas conductor' + end + +end diff --git a/spec/classes/cloud_database_dbaas_taskmanager_spec.rb b/spec/classes/cloud_database_dbaas_taskmanager_spec.rb new file mode 100644 index 00000000..8f5dfc03 --- /dev/null +++ b/spec/classes/cloud_database_dbaas_taskmanager_spec.rb @@ -0,0 +1,85 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for cloud::database::dbaas::taskmanager class +# + +require 'spec_helper' + +describe 'cloud::database::dbaas::taskmanager' do + + shared_examples_for 'openstack database dbaas taskmanager' do + + let :pre_condition do + "class { 'cloud::database::dbaas': + trove_db_host => '10.0.0.1', + trove_db_user => 'trove', + trove_db_password => 'secrete', + nova_admin_username => 'trove', + nova_admin_password => 'trovepassword', + nova_admin_tenant_name => 'services', + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete' }" + end + + let :params do + { :ks_keystone_internal_host => '10.0.0.1', + :ks_keystone_internal_port => '5000', + :ks_keystone_internal_proto => 'https', + :debug => true, + :verbose => true, + :use_syslog => true } + end + + it 'configure trove common' do + should contain_class('trove').with( + :rabbit_userid => 'trove', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :nova_proxy_admin_pass => 'trovepassword', + :nova_proxy_admin_user => 'trove', + :nova_proxy_admin_tenant_name => 'services', + :database_connection => 'mysql://trove:secrete@10.0.0.1/trove?charset=utf8', + ) + end + + it 'configure trove taskmanager' do + should contain_class('trove::taskmanager').with( + :verbose => true, + :debug => true, + :use_syslog => true, + :auth_url => 'https://10.0.0.1:5000/v2.0', + ) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack database dbaas taskmanager' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + it_configures 'openstack database dbaas taskmanager' + end + +end