diff --git a/README.rst b/README.rst index ded4ad0..0586c14 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ Description This cookbook provides a reference example of database configuration for the OpenStack deployment provided by Chef for OpenStack. It currently -supports MySQL and PostgreSQL. +supports MariaDB. Requirements ============ @@ -30,9 +30,7 @@ Cookbooks The following cookbooks are dependencies: -- 'mariadb', '~> 1.5' -- 'mysql2_chef_gem' , '~> 2.0' -- 'mysql', '~> 8.2' +- 'mariadb', '~> 3.1' - 'openstack-common', '~> 19.0.0' Usage @@ -70,16 +68,6 @@ server - Installs and configures server packages for the database used by the deployment. -mysql-client ------------- - -- Installs MySQL client packages and mysql client python packages. - -mysql-server ------------- - -- Configures the MySQL server for OpenStack. - mariadb-client -------------- diff --git a/attributes/mysql.rb b/attributes/mysql.rb index e44d65c..3a086ec 100644 --- a/attributes/mysql.rb +++ b/attributes/mysql.rb @@ -16,19 +16,10 @@ # limitations under the License. # -# MySQL attributes that we use the mysql cookbook defaults: - -# Data directory -default['openstack']['mysql']['data_dir'] = nil - # MySQL attributes that we select defaults for: -# Mysql version, support 5.7 and above -default['openstack']['mysql']['version'] = '5.7' # MariaDB version default['openstack']['mariadb']['version'] = '10.3' -# Service name -default['openstack']['mysql']['service_name'] = 'default' # Storage engine, base OpenStack requires the InnoDB flavor default['openstack']['mysql']['default-storage-engine'] = 'InnoDB' # InnoDB lock mode for generating auto-increment values diff --git a/metadata.rb b/metadata.rb index 87b4ac3..2b49e98 100755 --- a/metadata.rb +++ b/metadata.rb @@ -12,7 +12,6 @@ end depends 'openstack-common', '>= 19.0.0' depends 'mariadb', '~> 3.1' -depends 'mysql', '~> 8.6' issues_url 'https://launchpad.net/openstack-chef' source_url 'https://opendev.org/openstack/cookbook-openstack-ops-database' diff --git a/recipes/mysql-client.rb b/recipes/mysql-client.rb deleted file mode 100644 index 8d3176e..0000000 --- a/recipes/mysql-client.rb +++ /dev/null @@ -1,38 +0,0 @@ -# encoding: UTF-8 -# -# Cookbook:: openstack-ops-database -# Recipe:: mysql-client -# -# Copyright:: 2013, Opscode, Inc. -# Copyright:: 2013, AT&T Services, Inc. -# Copyright:: 2014, SUSE Linux, GmbH -# -# 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. -# - -mysql_client 'default' do - version node['openstack']['mysql']['version'] - action :create -end - -# install the mysql development headers -case node['platform_family'] -when 'debian' - package 'libmysqlclient-dev' -when 'rhel' - package 'mariadb-devel' -end - -node['openstack']['db']['python_packages']['mysql'].each do |pkg| - package pkg -end diff --git a/recipes/mysql-server.rb b/recipes/mysql-server.rb deleted file mode 100644 index ef4b001..0000000 --- a/recipes/mysql-server.rb +++ /dev/null @@ -1,51 +0,0 @@ -# encoding: UTF-8 -# -# Cookbook:: openstack-ops-database -# Recipe:: mysql-server -# -# Copyright:: 2013, Opscode, Inc. -# Copyright:: 2012-2013, Rackspace US, Inc. -# Copyright:: 2013, AT&T Services, Inc. -# -# 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 ::Chef::Recipe - include ::Openstack -end - -bind_db = node['openstack']['bind_service']['db'] -listen_address = if bind_db['interface'] - address_for bind_db['interface'] - else - listen_address = bind_db['host'] - end - -super_password = get_password 'db', node['openstack']['db']['root_user_key'] - -include_recipe 'openstack-ops-database::mysql-client' - -mysql_service node['openstack']['mysql']['service_name'] do - version node['openstack']['mysql']['version'] - data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir'] - initial_root_password super_password - bind_address listen_address - port bind_db['port'].to_s - action [:create, :start] -end - -mysql_config 'openstack' do - source 'openstack.cnf.erb' - notifies :restart, "mysql_service[#{node['openstack']['mysql']['service_name']}]" - action :create -end diff --git a/spec/mysql-client-redhat_spec.rb b/spec/mysql-client-redhat_spec.rb deleted file mode 100644 index 5a7a2af..0000000 --- a/spec/mysql-client-redhat_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# encoding: UTF-8 - -require_relative 'spec_helper' - -describe 'openstack-ops-database::mysql-client' do - include_context 'database-stubs' - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - it 'has default mysql client resource' do - expect(chef_run).to create_mysql_client 'default' - end - - it 'installs mysql packages' do - expect(chef_run).to install_package 'MySQL-python' - expect(chef_run).to install_package 'mariadb-devel' - end - end -end diff --git a/spec/mysql-client_spec.rb b/spec/mysql-client_spec.rb deleted file mode 100644 index e82c58c..0000000 --- a/spec/mysql-client_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# encoding: UTF-8 - -require_relative 'spec_helper' - -describe 'openstack-ops-database::mysql-client' do - include_context 'database-stubs' - describe 'ubuntu' do - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - it 'has default mysql client resource' do - expect(chef_run).to create_mysql_client 'default' - end - - it 'installs mysql packages' do - expect(chef_run).to install_package 'python3-mysqldb' - expect(chef_run).to install_package 'libmysqlclient-dev' - end - end -end diff --git a/spec/mysql-server_spec.rb b/spec/mysql-server_spec.rb deleted file mode 100644 index fdc1807..0000000 --- a/spec/mysql-server_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# encoding: UTF-8 - -require_relative 'spec_helper' - -describe 'openstack-ops-database::mysql-server' do - describe 'ubuntu' do - include_context 'database-stubs' - let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } - - it 'includes mysql recipes' do - expect(chef_run).to include_recipe 'openstack-ops-database::mysql-client' - end - - it 'creates mysql default service' do - expect(chef_run).to create_mysql_service('default').with( - version: '5.7', - data_dir: '/var/lib/mysql', - initial_root_password: 'abc123', - bind_address: '127.0.0.1', - port: '3306', - action: [:create, :start] - ) - end - - context 'creates mysql service with different values' do - cached(:chef_run) do - node.override['openstack']['mysql']['data_dir'] = '/other-dir' - node.override['openstack']['mysql']['version'] = '5.7' - runner.converge(described_recipe) - end - it do - expect(chef_run).to create_mysql_service('default').with( - version: '5.7', - data_dir: '/other-dir', - initial_root_password: 'abc123', - bind_address: '127.0.0.1', - port: '3306', - action: [:create, :start] - ) - end - end - - describe 'openstack.cnf' do - let(:file) { '/etc/mysql/conf.d/openstack.cnf' } - - it 'creates mysql openstack config and notifies server to restart' do - expect(chef_run).to create_mysql_config('openstack').with( - source: 'openstack.cnf.erb', - action: [:create] - ) - resource = chef_run.find_resource('mysql_config', 'openstack') - expect(resource).to notify('mysql_service[default]').to(:restart).delayed - end - - # TODO: Verify contents of openstack.cnf. This cannot be done properly at - # present because the mysql_config LWRP comes from the mysql cookbook but - # does not expose a custom matcher for testing the templates contents. - # See ChefSpec docs on testing LWRPs from other cookbooks. - # See issue filed against mysql cookbook: - # https://github.com/chef-cookbooks/mysql/issues/322 - end - end -end diff --git a/templates/default/openstack.cnf.erb b/templates/default/openstack.cnf.erb deleted file mode 100644 index 96d4887..0000000 --- a/templates/default/openstack.cnf.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%= node['openstack']['db']['custom_template_banner'] %> -[mysqld] -default-storage-engine = <%= node['openstack']['mysql']['default-storage-engine'] %> -innodb_autoinc_lock_mode = <%= node['openstack']['mysql']['innodb_autoinc_lock_mode'] %> -innodb_file_per_table = <%= node['openstack']['mysql']['innodb_file_per_table'] %> -innodb_thread_concurrency = <%= node['openstack']['mysql']['innodb_thread_concurrency'] %> -innodb_commit_concurrency = <%= node['openstack']['mysql']['innodb_commit_concurrency'] %> -innodb_read_io_threads = <%= node['openstack']['mysql']['innodb_read_io_threads'] %> -innodb_flush_log_at_trx_commit = <%= node['openstack']['mysql']['innodb_flush_log_at_trx_commit'] %> -innodb_buffer_pool_size = <%= node['openstack']['mysql']['innodb_buffer_pool_size'] %> -innodb_log_file_size = <%= node['openstack']['mysql']['innodb_log_file_size'] %> -innodb_log_buffer_size = <%= node['openstack']['mysql']['innodb_log_buffer_size'] %> -<%- if node['openstack']['mysql']['skip-name-resolve'] %> -skip-name-resolve -<%- end %> -character-set-server = <%= node['openstack']['mysql']['character-set-server'] %> -query_cache_size = <%= node['openstack']['mysql']['query_cache_size'] %> -max_connections = <%= node['openstack']['mysql']['max_connections'] %>