MySql cookbook ver 6 changes

mysql cookbook is now provider driver, and no longer has default
attributes, like server_root_password.
For the password, now always using the Common password methods.
Therefore the ['openstack']['db']['root_user_use_databag'] attribute
was removed, it's now the default path.

For the other mysql attributes we used, these were moved into the
ops-database cookbook.  See that patch for more info.

This patch requires updates to the database and mysql-chef-gem cookbooks.

Change-Id: I817030cd7fb56cb025e1a8e21dc2b956b0ad7911
Implements: blueprint trusty-juno
This commit is contained in:
Mark Vanderwiel 2015-02-12 15:12:32 -06:00
parent 8f0da303f9
commit 89c99e47be
5 changed files with 16 additions and 33 deletions

View File

@ -2,6 +2,10 @@
This file is used to list changes made in each version of cookbook-openstack-common.
## 10.3.0
* Updates for mysql cookbook ver 6.x
## 10.2.0
* Separate endpoints for vncserver_listen and vncserver_proxyclient_address
* Bump Chef gem to 11.16

View File

@ -197,12 +197,7 @@ default['openstack']['db']['database']['db_name'] = 'trove'
default['openstack']['db']['database']['username'] = 'trove'
default['openstack']['db']['database']['options'] = node['openstack']['db']['options']
# Switch to store the MySQL root password in a databag instead of
# using the generated OpenSSL cookbook secure_password one.
default['openstack']['db']['root_user_use_databag'] = false
# If above root_user_use_databag is true, the below string
# will be passed to the get_password library routine.
# DB key to the get_password library routine
default['openstack']['db']['root_user_key'] = 'mysqlroot'
# platform and DBMS-specific python client packages

View File

@ -29,7 +29,6 @@ module ::Openstack # rubocop:disable Documentation
# is used, the node['mysql']['server_root_password'] is used along
# with the 'root' (super)user.
def db_create_with_user(service, user, pass) # rubocop:disable CyclomaticComplexity, MethodLength
root_user_use_databag = node['openstack']['db']['root_user_use_databag']
info = db service
if info
host = info['host']
@ -42,25 +41,14 @@ module ::Openstack # rubocop:disable Documentation
db_prov = ::Chef::Provider::Database::Postgresql
user_prov = ::Chef::Provider::Database::PostgresqlUser
super_user = 'postgres'
if root_user_use_databag
user_key = node['openstack']['db']['root_user_key']
super_password = get_password 'user', user_key
else
super_password = node['postgresql']['password']['postgres']
end
user_key = node['openstack']['db']['root_user_key']
super_password = get_password 'user', user_key
when 'mysql'
# we have to install the 'mysql' gem, otherwise the provider won't work
include_recipe 'database::mysql'
db_prov = ::Chef::Provider::Database::Mysql
user_prov = ::Chef::Provider::Database::MysqlUser
super_user = 'root'
if root_user_use_databag
user_key = node['openstack']['db']['root_user_key']
super_password = get_password 'user', user_key
else
super_password = node['mysql']['server_root_password']
end
user_key = node['openstack']['db']['root_user_key']
super_password = get_password 'user', user_key
when 'db2'
db2_database 'create database' do
db_name db_name

View File

@ -4,7 +4,7 @@ maintainer_email 'opscode-chef-openstack@googlegroups.com'
license 'Apache 2.0'
description 'Common OpenStack attributes, libraries and recipes.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '10.2.0'
version '10.3.0'
recipe 'openstack-common', 'Installs/Configures common recipes'
recipe 'openstack-common::set_endpoints_by_interface', 'Set endpoints by interface'
@ -16,8 +16,8 @@ recipe 'openstack-common::openrc', 'Creates openrc file'
supports os
end
depends 'apt', '>= 2.3.8'
depends 'database', '>= 2.0.0'
depends 'mysql', '< 6.0.0'
depends 'yum', '>= 3.1.4'
depends 'yum-epel', '>= 0.3.4'
depends 'apt', '>= 2.3.8', '< 3.0.0'
depends 'database', '>= 4.0.2', '< 5.0.0'
depends 'mysql', '>= 6.0.13', '< 7.0.0'
depends 'yum', '>= 3.5.2', '< 4.0.0'
depends 'yum-epel', '>= 0.6.0', '< 1.0.0'

6
spec/database_spec.rb Normal file → Executable file
View File

@ -12,11 +12,6 @@ describe 'openstack-common::default' do
include_context 'library-stubs'
describe '#db_create_with_user' do
before do
allow(subject).to receive(:include_recipe)
.with('database::mysql')
.and_return('')
end
it 'returns nil when no such service was found' do
expect(
@ -34,6 +29,7 @@ describe 'openstack-common::default' do
end
end
allow(subject).to receive(:database_user).and_return({})
allow(subject).to receive(:get_password).with('user', 'mysqlroot').and_return('admin')
result = subject.db_create_with_user('compute', 'user', 'pass')
expect(result['host']).to eq('127.0.0.1')
expect(result['port']).to eq('3306')