Browse Source

ops-database refactor for Pike and Chef 13

- implemented foodcritic and cookstyle corrections
- deprecated node.foo.bar method access for node['foo']['bar'] bracket syntax
- removed deprecated postgresql support
- removed percona-cluster as the Percona cookbook has not been touched since 2015
- switched default rdbms to mariadb[0]

This change was largely born out of a discussion in #sous-chefs on the Chef
Community Slack. The notion of using the vendor-provided package is preferred
in the Chef Community versus the distro version if possible, due to
inconsistencies in outcome. As a result, this cookbook focuses on MariaDB, and
specifically from mariadb.org.

[0]: https://docs.openstack.org/install-guide/environment-sql-database.html

Implements blueprint modern-chef

Change-Id: I7ee0f5eae4e79e5c70ee8de4a0094a7c34fdd18f
Samuel Cassiba 1 year ago
parent
commit
45a1623cb2

+ 9
- 4
Berksfile View File

@@ -1,6 +1,11 @@
1
-source "https://supermarket.chef.io"
1
+source 'https://supermarket.chef.io'
2 2
 
3
-metadata
3
+%w(common).each do |cookbook|
4
+  if Dir.exist?("../cookbook-openstack-#{cookbook}")
5
+    cookbook "openstack-#{cookbook}", path: "../cookbook-openstack-#{cookbook}"
6
+  else
7
+    cookbook "openstack-#{cookbook}", github: "openstack/cookbook-openstack-#{cookbook}"
8
+  end
9
+end
4 10
 
5
-cookbook "openstack-common",
6
-  github: "openstack/cookbook-openstack-common"
11
+metadata

+ 176
- 0
LICENSE View File

@@ -0,0 +1,176 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+

+ 7
- 8
Rakefile View File

@@ -1,32 +1,32 @@
1 1
 task default: ["test"]
2 2
 
3
-task :test => [:syntax, :lint, :unit]
3
+task test: [:syntax, :lint, :unit]
4 4
 
5 5
 desc "Vendor the cookbooks in the Berksfile"
6 6
 task :berks_prep do
7
-  sh %{chef exec berks vendor}
7
+  sh %(chef exec berks vendor)
8 8
 end
9 9
 
10 10
 desc "Run FoodCritic (syntax) tests"
11 11
 task :syntax do
12
-  sh %{chef exec foodcritic --exclude spec -f any .}
12
+  sh %(chef exec foodcritic --exclude spec -f any .)
13 13
 end
14 14
 
15 15
 desc "Run RuboCop (lint) tests"
16 16
 task :lint do
17
-  sh %{chef exec cookstyle}
17
+  sh %(chef exec cookstyle)
18 18
 end
19 19
 
20 20
 desc "Run RSpec (unit) tests"
21
-task :unit => :berks_prep do
22
-  sh %{chef exec rspec --format documentation}
21
+task unit: :berks_prep do
22
+  sh %(chef exec rspec --format documentation)
23 23
 end
24 24
 
25 25
 desc "Remove the berks-cookbooks directory and the Berksfile.lock"
26 26
 task :clean do
27 27
   rm_rf [
28 28
     'berks-cookbooks',
29
-    'Berksfile.lock'
29
+    'Berksfile.lock',
30 30
   ]
31 31
 end
32 32
 
@@ -37,4 +37,3 @@ task :integration do
37 37
   load './Rakefile-Common'
38 38
   Rake::Task["common_integration"].invoke
39 39
 end
40
-

+ 2
- 7
metadata.rb View File

@@ -1,8 +1,8 @@
1 1
 name             'openstack-ops-database'
2 2
 maintainer       'openstack-chef'
3 3
 maintainer_email 'openstack-dev@lists.openstack.org'
4
-license          'Apache 2.0'
5
-description      'Provides the shared database configuration for Chef for OpenStack.'
4
+license          'Apache-2.0'
5
+description      'Provides the shared database configuration for OpenStack'
6 6
 version          '16.0.0'
7 7
 
8 8
 recipe 'client', 'Installs client packages for the database used by the deployment.'
@@ -11,8 +11,6 @@ recipe 'mysql-client', 'Installs MySQL client packages.'
11 11
 recipe 'mysql-server', 'Installs and configures MySQL server packages.'
12 12
 recipe 'mariadb-client', 'Installs MariaDB client packages.'
13 13
 recipe 'mariadb-server', 'Installs and configures MariaDB server packages.'
14
-recipe 'postgresql-client', 'Installs PostgreSQL client packages.'
15
-recipe 'postgresql-server', 'Installs and configures PostgreSQL server packages.'
16 14
 recipe 'openstack-db', 'Creates necessary tables, users, and grants for OpenStack.'
17 15
 
18 16
 %w(ubuntu redhat centos).each do |os|
@@ -21,12 +19,9 @@ end
21 19
 
22 20
 depends 'openstack-common', '>= 16.0.0'
23 21
 
24
-depends 'database', '~> 6.1'
25 22
 depends 'mariadb', '~> 1.5'
26 23
 depends 'mysql', '~> 8.2'
27 24
 depends 'mysql2_chef_gem', '~> 2.0'
28
-depends 'percona', '~> 0.16.1'
29
-depends 'postgresql', '~> 5.1'
30 25
 
31 26
 issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
32 27
 source_url 'https://github.com/openstack/cookbook-openstack-ops-database' if respond_to?(:source_url)

+ 2
- 2
recipes/mariadb-client.rb View File

@@ -16,11 +16,11 @@
16 16
 # limitations under the License.
17 17
 #
18 18
 
19
-node.override['mariadb']['install']['prefer_os_package'] = true
19
+node.normal['mariadb']['use_default_repository'] = true
20 20
 include_recipe 'mariadb::client'
21 21
 
22 22
 mysql2_chef_gem_mariadb 'default' do
23
-  gem_version '0.4.5'
23
+  gem_version '0.4.9'
24 24
   action :install
25 25
 end
26 26
 

+ 7
- 34
recipes/mariadb-server.rb View File

@@ -30,20 +30,20 @@ listen_address = if bind_db['interface']
30 30
 
31 31
 super_password = get_password 'db', node['openstack']['db']['root_user_key']
32 32
 
33
-node.override['mariadb']['allow_root_pass_change'] = true
34
-node.override['mariadb']['server_root_password'] = super_password
35
-node.override['mariadb']['mysqld']['bind_address'] = listen_address
36
-node.override['mariadb']['install']['prefer_os_package'] = true
33
+node.normal['mariadb']['remove_test_database'] = true
34
+node.normal['mariadb']['allow_root_pass_change'] = true
35
+node.normal['mariadb']['server_root_password'] = super_password
36
+node.normal['mariadb']['mysqld']['bind_address'] = listen_address
37 37
 
38 38
 unless listen_address == '127.0.0.1' || listen_address == 'localhost'
39
-  node.override['mariadb']['forbid_remote_root'] = false
39
+  node.normal['mariadb']['forbid_remote_root'] = false
40 40
 end
41 41
 
42 42
 include_recipe 'openstack-ops-database::mariadb-client'
43 43
 
44 44
 # reuse mysql configuration for mariadb
45
-node.override['mariadb']['mysqld']['default_storage_engine'] = node['openstack']['mysql']['default-storage-engine']
46
-node.override['mariadb']['mysqld']['max_connections'] = node['openstack']['mysql']['max_connections']
45
+node.normal['mariadb']['mysqld']['default_storage_engine'] = node['openstack']['mysql']['default-storage-engine']
46
+node.normal['mariadb']['mysqld']['max_connections'] = node['openstack']['mysql']['max_connections']
47 47
 include_recipe 'mariadb::server'
48 48
 
49 49
 # reuse mysql configuration file for mariadb
@@ -53,30 +53,3 @@ template "#{node['mariadb']['configuration']['includedir']}/openstack.cnf" do
53 53
   source 'openstack.cnf.erb'
54 54
   notifies :restart, 'service[mysql]'
55 55
 end
56
-
57
-# Current mariadb cookbook does not handle deleting anonymous users and default
58
-# users. We need to delete them here.
59
-mysql_connection_info = {
60
-  host: 'localhost',
61
-  username: 'root',
62
-  password: super_password,
63
-}
64
-
65
-mysql_database 'drop empty and default users' do
66
-  database_name 'mysql'
67
-  sql "DELETE FROM mysql.user WHERE User = '' OR Password = ''"
68
-  connection mysql_connection_info
69
-  action :query
70
-end
71
-
72
-mysql_database 'test' do
73
-  connection mysql_connection_info
74
-  action :drop
75
-end
76
-
77
-mysql_database 'flush priviledges after cleanup' do
78
-  database_name 'mysql'
79
-  sql 'FLUSH PRIVILEGES'
80
-  connection mysql_connection_info
81
-  action :query
82
-end

+ 1
- 1
recipes/mysql-server.rb View File

@@ -40,7 +40,7 @@ mysql_service node['openstack']['mysql']['service_name'] do
40 40
   data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir']
41 41
   initial_root_password super_password
42 42
   bind_address listen_address
43
-  port bind_db.port.to_s
43
+  port bind_db['port'].to_s
44 44
   action [:create, :start]
45 45
 end
46 46
 

+ 0
- 28
recipes/percona-cluster-client.rb View File

@@ -1,28 +0,0 @@
1
-# encoding: UTF-8
2
-#
3
-# Cookbook Name:: openstack-ops-database
4
-# Recipe:: percona-cluster-client
5
-#
6
-# Licensed under the Apache License, Version 2.0 (the "License");
7
-# you may not use this file except in compliance with the License.
8
-# You may obtain a copy of the License at
9
-#
10
-#     http://www.apache.org/licenses/LICENSE-2.0
11
-#
12
-# Unless required by applicable law or agreed to in writing, software
13
-# distributed under the License is distributed on an "AS IS" BASIS,
14
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
-# See the License for the specific language governing permissions and
16
-# limitations under the License.
17
-#
18
-
19
-include_recipe 'percona::client'
20
-
21
-mysql2_chef_gem 'default' do
22
-  provider Chef::Provider::Mysql2ChefGem::Percona
23
-  action :install
24
-end
25
-
26
-node['openstack']['db']['python_packages']['percona-cluster'].each do |pkg|
27
-  package pkg
28
-end

+ 0
- 62
recipes/percona-cluster-server.rb View File

@@ -1,62 +0,0 @@
1
-# encoding: UTF-8
2
-#
3
-# Cookbook Name:: openstack-ops-database
4
-# Recipe:: percona-cluster-server
5
-#
6
-# Licensed under the Apache License, Version 2.0 (the "License");
7
-# you may not use this file except in compliance with the License.
8
-# You may obtain a copy of the License at
9
-#
10
-#     http://www.apache.org/licenses/LICENSE-2.0
11
-#
12
-# Unless required by applicable law or agreed to in writing, software
13
-# distributed under the License is distributed on an "AS IS" BASIS,
14
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
-# See the License for the specific language governing permissions and
16
-# limitations under the License.
17
-#
18
-
19
-class ::Chef::Recipe
20
-  include ::Openstack
21
-end
22
-
23
-## INFO: to use this recipe, set node['percona']['server']['role'] = %w(cluster) in your environment
24
-
25
-bind_db = node['openstack']['bind_service']['db']
26
-if bind_db['interface']
27
-  listen_address = address_for bind_db['interface']
28
-  node.normal['percona']['cluster']['wsrep_sst_receive_address'] = listen_address
29
-  node.normal['percona']['server']['bind_address'] = listen_address
30
-  node.normal['percona']['server']['port'] = bind_db['port']
31
-else
32
-  listen_address = bind_db['host']
33
-  node.normal['percona']['server']['bind_address'] = listen_address
34
-  node.normal['percona']['server']['port'] = node['openstack']['endpoints']['db']['port']
35
-end
36
-
37
-## CLUSTER SPECIFIC CONFIG
38
-node.normal['percona']['cluster']['wsrep_node_name'] = node['fqdn']
39
-node.normal['percona']['cluster']['wsrep_cluster_name'] = 'openstack'
40
-node.normal['percona']['cluster']['wsrep_provider_options'] = "\"gmcast.listen_addr=tcp://#{listen_address}:4567;\""
41
-# query_cache is not supported with wsrep
42
-node.normal['percona']['server']['query_cache_size'] = 0
43
-# find all nodes in the percona cluster
44
-cluster_nodes = search(:node, 'recipes:"percona\:\:cluster"').sort
45
-# if it's the first node make sure that wsrep_cluster_address is set to nothing to be able to bootstrap.
46
-is_first_node = cluster_nodes.empty? || (cluster_nodes.size == 1 && cluster_nodes.first['fqdn'] == node['fqdn'])
47
-if is_first_node
48
-  node.normal['percona']['cluster']['wsrep_cluster_address'] = 'gcomm://'
49
-else
50
-  # otherwise set the correct cluster address with all cluster nodes
51
-  family = node['openstack']['endpoints']['family']
52
-  cluster_nodes_addresses = []
53
-  cluster_nodes.each do |cluster_node|
54
-    address = address_for bind_db['interface'], family, cluster_node
55
-    cluster_nodes_addresses << address
56
-  end
57
-  cluster_address = cluster_nodes_addresses.join(',')
58
-  node.normal['percona']['cluster']['wsrep_cluster_address'] = "gcomm://#{cluster_address}"
59
-end
60
-
61
-include_recipe 'openstack-ops-database::percona-cluster-client'
62
-include_recipe 'percona::cluster'

+ 0
- 28
recipes/postgresql-client.rb View File

@@ -1,28 +0,0 @@
1
-# encoding: UTF-8
2
-#
3
-# Cookbook Name:: openstack-ops-database
4
-# Recipe:: postgresql-client
5
-#
6
-# Copyright 2013, Opscode, Inc.
7
-# Copyright 2013, AT&T Services, Inc.
8
-# Copyright 2013-2014, SUSE Linux GmbH
9
-#
10
-# Licensed under the Apache License, Version 2.0 (the "License");
11
-# you may not use this file except in compliance with the License.
12
-# You may obtain a copy of the License at
13
-#
14
-#     http://www.apache.org/licenses/LICENSE-2.0
15
-#
16
-# Unless required by applicable law or agreed to in writing, software
17
-# distributed under the License is distributed on an "AS IS" BASIS,
18
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
-# See the License for the specific language governing permissions and
20
-# limitations under the License.
21
-#
22
-
23
-include_recipe 'postgresql::ruby'
24
-include_recipe 'postgresql::client'
25
-
26
-node['openstack']['db']['python_packages']['postgresql'].each do |pkg|
27
-  package pkg
28
-end

+ 0
- 38
recipes/postgresql-server.rb View File

@@ -1,38 +0,0 @@
1
-# encoding: UTF-8
2
-#
3
-# Cookbook Name:: openstack-ops-database
4
-# Recipe:: postgresql-server
5
-#
6
-# Copyright 2013, Opscode, Inc.
7
-# Copyright 2012-2013, Rackspace US, Inc.
8
-# Copyright 2013, AT&T Services, Inc.
9
-# Copyright 2013, SUSE Linux GmbH
10
-#
11
-# Licensed under the Apache License, Version 2.0 (the "License");
12
-# you may not use this file except in compliance with the License.
13
-# You may obtain a copy of the License at
14
-#
15
-#     http://www.apache.org/licenses/LICENSE-2.0
16
-#
17
-# Unless required by applicable law or agreed to in writing, software
18
-# distributed under the License is distributed on an "AS IS" BASIS,
19
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
-# See the License for the specific language governing permissions and
21
-# limitations under the License.
22
-#
23
-
24
-class ::Chef::Recipe
25
-  include ::Openstack
26
-end
27
-
28
-bind_db = node['openstack']['bind_service']['db']
29
-listen_address = if bind_db['interface']
30
-                   address_for bind_db['interface']
31
-                 else
32
-                   bind_db['host']
33
-                 end
34
-
35
-node.override['postgresql']['config']['listen_addresses'] = listen_address
36
-
37
-include_recipe 'openstack-ops-database::postgresql-client'
38
-include_recipe 'postgresql::server'

+ 3
- 9
spec/client_spec.rb View File

@@ -9,15 +9,9 @@ describe 'openstack-ops-database::client' do
9 9
     let(:node) { runner.node }
10 10
     let(:chef_run) { runner.converge(described_recipe) }
11 11
 
12
-    it 'uses mysql database client recipe by default' do
13
-      expect(chef_run).to include_recipe 'openstack-ops-database::mysql-client'
14
-    end
15
-
16
-    it 'uses postgresql database client recipe when configured' do
17
-      node.set['openstack']['db']['service_type'] = 'postgresql'
18
-      node.set['postgresql']['password']['postgres'] = 'secret'
19
-
20
-      expect(chef_run).to include_recipe 'openstack-ops-database::postgresql-client'
12
+    it 'uses mariadb client recipe by default' do
13
+      node.set['openstack']['db']['service_type'] = 'mariadb'
14
+      expect(chef_run).to include_recipe 'openstack-ops-database::mariadb-client'
21 15
     end
22 16
   end
23 17
 end

+ 1
- 1
spec/mariadb-client-redhat_spec.rb View File

@@ -6,7 +6,7 @@ describe 'openstack-ops-database::mariadb-client' do
6 6
   describe 'redhat' do
7 7
     let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
8 8
     let(:node) do
9
-      runner.node.set['openstack']['db']['service_type'] = 'mariadb'
9
+      runner.node.override['openstack']['db']['service_type'] = 'mariadb'
10 10
       runner.node
11 11
     end
12 12
     let(:chef_run) { runner.converge(described_recipe) }

+ 1
- 5
spec/mariadb-client_spec.rb View File

@@ -7,7 +7,7 @@ describe 'openstack-ops-database::mariadb-client' do
7 7
   describe 'ubuntu' do
8 8
     let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
9 9
     let(:node) do
10
-      runner.node.set['openstack']['db']['service_type'] = 'mariadb'
10
+      runner.node.override['openstack']['db']['service_type'] = 'mariadb'
11 11
       runner.node
12 12
     end
13 13
     let(:chef_run) { runner.converge(described_recipe) }
@@ -19,9 +19,5 @@ describe 'openstack-ops-database::mariadb-client' do
19 19
     it 'installs mariadb python client packages' do
20 20
       expect(chef_run).to install_package('python-mysqldb')
21 21
     end
22
-
23
-    it 'override prefer os package' do
24
-      expect(chef_run.node['mariadb']['install']['prefer_os_package']).to be true
25
-    end
26 22
   end
27 23
 end

+ 1
- 1
spec/mariadb-server-redhat_spec.rb View File

@@ -11,7 +11,7 @@ describe 'openstack-ops-database::mariadb-server' do
11 11
     let(:file) { chef_run.template('/etc/my.cnf.d/openstack.cnf') }
12 12
 
13 13
     it 'creates template /etc/my.cnf.d/openstack.cnf' do
14
-      node.set['mariadb']['install']['version'] = '5.7'
14
+      node.override['mariadb']['install']['version'] = '5.7'
15 15
       expect(chef_run).to create_template(file.name).with(
16 16
         user: 'mysql',
17 17
         group: 'mysql',

+ 4
- 16
spec/mariadb-server_spec.rb View File

@@ -15,6 +15,8 @@ describe 'openstack-ops-database::mariadb-server' do
15 15
       expect(chef_run.node['mariadb']['mysqld']['default_storage_engine']).to eq 'InnoDB'
16 16
       expect(chef_run.node['mariadb']['mysqld']['max_connections']).to eq '307'
17 17
       expect(chef_run.node['mariadb']['forbid_remote_root']).to be true
18
+      expect(chef_run.node['mariadb']['remove_anonymous_users']).to be true
19
+      expect(chef_run.node['mariadb']['remove_test_database']).to be true
18 20
     end
19 21
 
20 22
     it 'includes mariadb recipes' do
@@ -23,7 +25,7 @@ describe 'openstack-ops-database::mariadb-server' do
23 25
     end
24 26
 
25 27
     it 'creates template /etc/mysql/conf.d/openstack.cnf' do
26
-      node.set['mariadb']['install']['version'] = '5.7'
28
+      node.override['mariadb']['install']['version'] = '10.1'
27 29
       expect(chef_run).to create_template(file.name).with(
28 30
         user: 'mysql',
29 31
         group: 'mysql',
@@ -54,23 +56,9 @@ describe 'openstack-ops-database::mariadb-server' do
54 56
       expect(chef_run.node['mariadb']['server_root_password']).to eq 'abc123'
55 57
     end
56 58
 
57
-    it 'override prefer os package' do
58
-      expect(chef_run.node['mariadb']['install']['prefer_os_package']).to be true
59
-    end
60
-
61 59
     it 'allow root remote access' do
62
-      node.set['openstack']['bind_service']['db']['host'] = '192.168.1.1'
60
+      node.override['openstack']['bind_service']['db']['host'] = '192.168.1.1'
63 61
       expect(chef_run.node['mariadb']['forbid_remote_root']).to be false
64 62
     end
65
-
66
-    it 'drop anonymous and empty users' do
67
-      expect(chef_run).to query_mysql_database('drop empty and default users')\
68
-        .with(database_name: 'mysql',
69
-              sql: "DELETE FROM mysql.user WHERE User = '' OR Password = ''")
70
-      expect(chef_run).to drop_mysql_database('test')
71
-      expect(chef_run).to query_mysql_database('flush priviledges after cleanup')\
72
-        .with(database_name: 'mysql',
73
-              sql: 'FLUSH PRIVILEGES')
74
-    end
75 63
   end
76 64
 end

+ 0
- 28
spec/percona-cluster-client_spec.rb View File

@@ -1,28 +0,0 @@
1
-# encoding: UTF-8
2
-
3
-require_relative 'spec_helper'
4
-
5
-describe 'openstack-ops-database::percona-cluster-client' do
6
-  include_context 'database-stubs'
7
-  describe 'ubuntu' do
8
-    let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
9
-    let(:node) do
10
-      runner.node.set['openstack']['db']['service_type'] = 'percona-cluster'
11
-      runner.node
12
-    end
13
-    let(:chef_run) { runner.converge(described_recipe) }
14
-
15
-    it 'includes percona client recipes' do
16
-      expect(chef_run).to include_recipe('percona::client')
17
-    end
18
-
19
-    it 'install mysql2 gem package' do
20
-      expect(chef_run).to install_mysql2_chef_gem('default')
21
-        .with(provider: Chef::Provider::Mysql2ChefGem::Percona)
22
-    end
23
-
24
-    it 'installs percona python client packages' do
25
-      expect(chef_run).to install_package('python-mysqldb')
26
-    end
27
-  end
28
-end

+ 0
- 19
spec/percona-cluster-server_spec.rb View File

@@ -1,19 +0,0 @@
1
-# encoding: UTF-8
2
-
3
-require_relative 'spec_helper'
4
-
5
-describe 'openstack-ops-database::percona-cluster-server' do
6
-  include_context 'database-stubs'
7
-  describe 'ubuntu' do
8
-    let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
9
-    let(:node) do
10
-      runner.node.set['openstack']['db']['service_type'] = 'percona-cluster'
11
-      runner.node
12
-    end
13
-    let(:chef_run) { runner.converge(described_recipe) }
14
-
15
-    it 'includes percona client recipes' do
16
-      expect(chef_run).to include_recipe('percona::cluster')
17
-    end
18
-  end
19
-end

+ 0
- 27
spec/postgresql-server_spec.rb View File

@@ -1,27 +0,0 @@
1
-# encoding: UTF-8
2
-
3
-require_relative 'spec_helper'
4
-
5
-describe 'openstack-ops-database::postgresql-server' do
6
-  describe 'ubuntu' do
7
-    include_context 'database-stubs'
8
-
9
-    let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
10
-    let(:node) { runner.node }
11
-    let(:chef_run) do
12
-      # The postgresql cookbook will raise an 'uninitialized constant
13
-      # Chef::Application' error without this attribute when running
14
-      # the tests
15
-      node.set['postgresql']['password']['postgres'] = 'postgres_password'
16
-
17
-      runner.converge(described_recipe)
18
-    end
19
-
20
-    it 'includes postgresql recipes' do
21
-      expect(chef_run).to include_recipe(
22
-        'openstack-ops-database::postgresql-client'
23
-      )
24
-      expect(chef_run).to include_recipe('postgresql::server')
25
-    end
26
-  end
27
-end

+ 3
- 14
spec/server_spec.rb View File

@@ -9,20 +9,9 @@ describe 'openstack-ops-database::server' do
9 9
     let(:node) { runner.node }
10 10
     let(:chef_run) { runner.converge(described_recipe) }
11 11
 
12
-    it 'uses mysql database server recipe by default' do
13
-      expect(chef_run).to include_recipe('openstack-ops-database::mysql-server')
14
-    end
15
-
16
-    it 'uses postgresql database server recipe when configured' do
17
-      node.set['openstack']['db']['service_type'] = 'postgresql'
18
-      # The postgresql cookbook will raise an 'uninitialized constant
19
-      # Chef::Application' error without this attribute when running
20
-      # the tests
21
-      node.set['postgresql']['password']['postgres'] = 'postgres_password'
22
-
23
-      expect(chef_run).to include_recipe(
24
-        'openstack-ops-database::postgresql-server'
25
-      )
12
+    it 'uses mariadb server recipe by default' do
13
+      node.set['openstack']['db']['service_type'] = 'mariadb'
14
+      expect(chef_run).to include_recipe('openstack-ops-database::mariadb-server')
26 15
     end
27 16
   end
28 17
 end

+ 1
- 4
spec/spec_helper.rb View File

@@ -7,7 +7,7 @@ ChefSpec::Coverage.start! { add_filter 'openstack-ops-database' }
7 7
 LOG_LEVEL = :fatal
8 8
 REDHAT_OPTS = {
9 9
   platform: 'redhat',
10
-  version: '7.1',
10
+  version: '7.3',
11 11
   log_level: ::LOG_LEVEL,
12 12
 }.freeze
13 13
 UBUNTU_OPTS = {
@@ -23,9 +23,6 @@ shared_context 'database-stubs' do
23 23
     # for debian
24 24
     stub_command("\"/usr/bin/mysql\" -u root -e 'show databases;'")
25 25
     stub_command("mysqladmin --user=root --password='' version")
26
-    # for postgresql
27
-    stub_command('ls /var/lib/postgresql/9.5/main/recovery.conf')
28
-    stub_search('node', "recipes:\"percona\\:\\:cluster\"").and_return([])
29 26
 
30 27
     allow_any_instance_of(Chef::Recipe).to receive(:address_for)
31 28
       .with('lo')

Loading…
Cancel
Save