From 27911c00eb0f20f3739efa7ec24960430882b5de Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Mon, 27 May 2013 12:05:12 -0400 Subject: [PATCH] Brings in Matt's openstack-ops-database work Just bring in Matt's original work on the ops-database cookbook. Corrects what I think was a typo for the database service role name attribute from openstack::role::database to openstack::database::server_role Brings in Berksfile and Gemfile and stubbed specs to pass gates. Also sets version to 7.0.0 to match semantic versions of openstack project cookbooks. Change-Id: Idc02435ff7d3ff4b8a04c2bfc5abbb1e3091cb68 --- .gitignore | 5 + .gitreview | 4 + Berksfile | 1 + CHANGELOG.md | 5 +- Gemfile | 6 ++ Gemfile.lock | 198 ++++++++++++++++++++++++++++++++++++++++ README.md | 35 +++++-- attributes/default.rb | 11 +++ metadata.rb | 16 ++++ recipes/client.rb | 20 ++++ recipes/mysql-client.rb | 23 +++++ recipes/mysql-server.rb | 63 +++++++++++++ recipes/server.rb | 20 ++++ spec/default_spec.rb | 4 + spec/spec_helper.rb | 13 +++ 15 files changed, 414 insertions(+), 10 deletions(-) create mode 100644 .gitignore create mode 100644 .gitreview create mode 100644 Berksfile create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 attributes/default.rb create mode 100644 metadata.rb create mode 100644 recipes/client.rb create mode 100644 recipes/mysql-client.rb create mode 100644 recipes/mysql-server.rb create mode 100644 recipes/server.rb create mode 100644 spec/default_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7903d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.swp +*~ +.bundle +.cookbooks/ +Berksfile.lock diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..fd98bf3 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cookbook-openstack-ops-database.git diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..850a120 --- /dev/null +++ b/Berksfile @@ -0,0 +1 @@ +metadata diff --git a/CHANGELOG.md b/CHANGELOG.md index d485638..fa14ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ -## 2013.1.0 +## 7.0.0 -* initial release +* Initial release intended for Grizzly-based OpenStack releases, + for use with Stackforge upstream repositories. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ec9d752 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "chef", "~> 10.18.2" +gem "berkshelf", "~> 1.4.0" +gem "chefspec", "~> 1.2.0" +gem "foodcritic", "~> 2.1.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0377802 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,198 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.2.13) + i18n (= 0.6.1) + multi_json (~> 1.0) + addressable (2.3.4) + akami (1.2.0) + gyoku (>= 0.4.0) + nokogiri (>= 1.4.0) + berkshelf (1.4.4) + activesupport (>= 3.2.0) + addressable + celluloid (>= 0.14.0) + chozo (>= 0.6.1) + faraday (>= 0.8.5) + hashie (>= 2.0.2) + json (>= 1.5.0) + minitar + mixlib-config (~> 1.1) + mixlib-shellout (~> 1.1) + multi_json (~> 1.5) + retryable + ridley (~> 0.12.1) + solve (>= 0.4.2) + thor (~> 0.18.0) + yajl-ruby + builder (3.2.0) + bunny (0.7.9) + celluloid (0.14.0) + timers (>= 1.0.0) + chef (10.18.2) + bunny (>= 0.6.0, < 0.8.0) + erubis + highline (>= 1.6.9) + json (>= 1.4.4, <= 1.6.1) + mixlib-authentication (>= 1.3.0) + mixlib-cli (>= 1.1.0) + mixlib-config (>= 1.1.2) + mixlib-log (>= 1.3.0) + mixlib-shellout + moneta (< 0.7.0) + net-ssh (~> 2.2.2) + net-ssh-multi (~> 1.1.0) + ohai (>= 0.6.0) + rest-client (>= 1.0.4, < 1.7.0) + treetop (~> 1.4.9) + uuidtools + yajl-ruby (~> 1.1) + chefspec (1.2.0) + chef (>= 10.0) + erubis + fauxhai (>= 0.1.1, < 2.0) + minitest-chef-handler (>= 0.6.0) + rspec (~> 2.0) + chozo (0.6.1) + activesupport (>= 3.2.0) + hashie (>= 2.0.2) + multi_json (>= 1.3.0) + ci_reporter (1.8.4) + builder (>= 2.1.2) + diff-lcs (1.2.4) + erubis (2.7.0) + faraday (0.8.7) + multipart-post (~> 1.1) + fauxhai (1.1.0) + httparty + net-ssh + ohai + ffi (1.8.1) + foodcritic (2.1.0) + erubis + gherkin (~> 2.11.7) + nokogiri (~> 1.5.4) + rak (~> 1.4) + treetop (~> 1.4.10) + yajl-ruby (~> 1.1.0) + gherkin (2.11.8) + multi_json (~> 1.3) + gssapi (1.0.3) + ffi (>= 1.0.1) + gyoku (1.0.0) + builder (>= 2.1.2) + hashie (2.0.5) + highline (1.6.19) + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) + httpclient (2.2.0.2) + httpi (0.9.7) + rack + i18n (0.6.1) + ipaddress (0.8.0) + json (1.6.1) + little-plugger (1.1.3) + logging (1.6.2) + little-plugger (>= 1.1.3) + mime-types (1.23) + minitar (0.5.4) + minitest (4.7.4) + minitest-chef-handler (1.0.1) + chef + ci_reporter + minitest (~> 4.7.3) + mixlib-authentication (1.3.0) + mixlib-log + mixlib-cli (1.3.0) + mixlib-config (1.1.2) + mixlib-log (1.6.0) + mixlib-shellout (1.1.0) + moneta (0.6.0) + multi_json (1.7.4) + multi_xml (0.5.3) + multipart-post (1.2.0) + net-http-persistent (2.8) + net-ssh (2.2.2) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + net-ssh-multi (1.1) + net-ssh (>= 2.1.4) + net-ssh-gateway (>= 0.99.0) + nokogiri (1.5.9) + nori (1.1.5) + ohai (6.16.0) + ipaddress + mixlib-cli + mixlib-config + mixlib-log + mixlib-shellout + systemu + yajl-ruby + polyglot (0.3.3) + rack (1.5.2) + rak (1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + retryable (1.3.3) + ridley (0.12.3) + addressable + celluloid (~> 0.14.0) + chozo (>= 0.6.0) + erubis + faraday (>= 0.8.4) + mixlib-authentication (>= 1.3.0) + mixlib-config (>= 1.1.0) + mixlib-log (>= 1.3.0) + mixlib-shellout (>= 1.1.0) + net-http-persistent (>= 2.8) + net-ssh + retryable + solve (>= 0.4.4) + winrm (~> 1.1.0) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + rubyntlm (0.1.1) + savon (0.9.5) + akami (~> 1.0) + builder (>= 2.1.2) + gyoku (>= 0.4.0) + httpi (~> 0.9) + nokogiri (>= 1.4.0) + nori (~> 1.0) + wasabi (~> 1.0) + solve (0.4.4) + json + systemu (2.5.2) + thor (0.18.1) + timers (1.1.0) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + uuidtools (2.1.4) + wasabi (1.0.0) + nokogiri (>= 1.4.0) + winrm (1.1.2) + gssapi (~> 1.0.0) + httpclient (~> 2.2.0.2) + logging (~> 1.6.1) + nokogiri (~> 1.5.0) + rubyntlm (~> 0.1.1) + savon (= 0.9.5) + uuidtools (~> 2.1.2) + yajl-ruby (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + berkshelf (~> 1.4.0) + chef (~> 10.18.2) + chefspec (~> 1.2.0) + foodcritic (~> 2.1.0) diff --git a/README.md b/README.md index 3ead154..02d9b16 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,41 @@ Chef 11 with Ruby 1.9.x required. The following cookbooks are dependencies: * database +* mysql # Resources/Providers # None -# Recipes # - -## default ## - -- configures the database selected by attributes - -# Attributes # - # Templates # None +# Recipes # + +## client ## + +- database client configuration, selected by attributes + +## server ## + +- database server configuration, selected by attributes + +## mysql-client ## + +- calls mysql::ruby and mysql::client and installs 'mysql_python_packages' + +## mysql-server ## + +- configures the mysql server for OpenStack + +# Attributes # + +* `openstack['database']['server_role']` - which role should other nodes search on to find the database service, defaults to 'os-ops-database' + +* `openstack['database']['service']` - which service to use, defaults to 'mysql' +* `openstack['database']['platform']['mysql_python_packages']` - platform-specific mysql python packages to install + License and Author ================== @@ -44,6 +62,7 @@ License and Author | **Author** | William Kelly () | | **Author** | Darren Birkett () | | **Author** | Evan Callicoat () | +| **Author** | Matt Thompson () | | **Author** | Matt Ray () | | | | | **Copyright** | Copyright (c) 2012-2013, Rackspace US, Inc. | diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..fedc70e --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1,11 @@ +default['openstack']['database']['server_role'] = 'os-ops-database' + +default['openstack']['database']['service'] = 'mysql' + +# platform defaults +case platform +when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this + default['openstack']['database']['platform']['mysql_python_packages'] = [ 'MySQL-python' ] +when 'ubuntu' + default['openstack']['database']['platform']['mysql_python_packages'] = [ 'python-mysqldb' ] +end diff --git a/metadata.rb b/metadata.rb new file mode 100644 index 0000000..bd2ebe5 --- /dev/null +++ b/metadata.rb @@ -0,0 +1,16 @@ +name "openstack-ops-database" +maintainer "Opscode, Inc." +maintainer_email "matt@opscode.com" +license "Apache 2.0" +description "Provides the shared database configuration for Chef for OpenStack." +version "7.0.0" + +recipe "client", "Installs client CLI package for the database used by the deployment." +recipe "server", "Installs and configures server packages for the database used by the deployment." + +%w{ ubuntu redhat fedora centos }.each do |os| + supports os +end + +depends "database", ">= 1.3.12" +depends "mysql", ">= 3.0.0" diff --git a/recipes/client.rb b/recipes/client.rb new file mode 100644 index 0000000..16d91dd --- /dev/null +++ b/recipes/client.rb @@ -0,0 +1,20 @@ +# +# Cookbook Name:: openstack-ops-database +# Recipe:: client +# +# Copyright 2013, Opscode, 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. +# + +include_recipe "openstack-ops-database::#{node['openstack']['database']['service']}-client" diff --git a/recipes/mysql-client.rb b/recipes/mysql-client.rb new file mode 100644 index 0000000..b7def7f --- /dev/null +++ b/recipes/mysql-client.rb @@ -0,0 +1,23 @@ +# +# Cookbook Name:: openstack-ops-database +# Recipe:: mysql-client +# +# Copyright 2013, Opscode, 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. +# + +include_recipe "mysql::ruby" +include_recipe "mysql::client" + +node.default['openstack']['packages']['ops-database::mysql-client'] = node['openstack']['database']['platform']['mysql_python_packages'] diff --git a/recipes/mysql-server.rb b/recipes/mysql-server.rb new file mode 100644 index 0000000..bd78201 --- /dev/null +++ b/recipes/mysql-server.rb @@ -0,0 +1,63 @@ +# +# Cookbook Name:: openstack-ops-database +# Recipe:: mysql-server +# +# Copyright 2013, Opscode, Inc. +# Copyright 2012-2013, Rackspace US, 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. +# + +# override default attributes in the upstream mysql cookbook +node.set["mysql"]["bind_address"] = bind_ip = "0.0.0.0" +node.set['mysql']['tunable']['innodb_thread_concurrency'] = "0" +node.set['mysql']['tunable']['innodb_commit_concurrency'] = "0" +node.set['mysql']['tunable']['innodb_read_io_threads'] = "4" +node.set['mysql']['tunable']['innodb_flush_log_at_trx_commit'] = "2" + +include_recipe "openstack-ops-database::mysql-client" +include_recipe "mysql::server" + +mysql_connection_info = {:host => "localhost", + :username => 'root', + :password => node['mysql']['server_root_password']} + +# removing insecure default mysql users +mysql_database_user 'drop empty localhost user' do + username '' + host 'localhost' + connection mysql_connection_info + action :drop +end + +# removing insecure default mysql users +mysql_database_user 'drop empty hostname user' do + username '' + host node['hostname'] + connection mysql_connection_info + action :drop +end + +# drop the test database +mysql_database 'test' do + connection mysql_connection_info + action :drop +end + +# flush the privileges +mysql_database "FLUSH privileges" do + connection mysql_connection_info + sql "FLUSH privileges" + action :nothing + subscribes :query, "mysql_database[test]" +end diff --git a/recipes/server.rb b/recipes/server.rb new file mode 100644 index 0000000..f0aee1e --- /dev/null +++ b/recipes/server.rb @@ -0,0 +1,20 @@ +# +# Cookbook Name:: openstack-ops-database +# Recipe:: server +# +# Copyright 2013, Opscode, 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. +# + +include_recipe "openstack-ops-database::#{node['openstack']['database']['service']}-server" diff --git a/spec/default_spec.rb b/spec/default_spec.rb new file mode 100644 index 0000000..996e330 --- /dev/null +++ b/spec/default_spec.rb @@ -0,0 +1,4 @@ +require "spec_helper" + +describe "openstack-ops-database::default" do +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0389331 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,13 @@ +require "chefspec" + +::LOG_LEVEL = :fatal +::REDHAT_OPTS = { + :platform => "redhat", + :version => "6.3", + :log_level => ::LOG_LEVEL +} +::UBUNTU_OPTS = { + :platform => "ubuntu", + :version => "12.04", + :log_level => ::LOG_LEVEL +}