summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Klare <j.klare@x-ion.de>2016-02-11 07:37:11 +0100
committerMark Vanderwiel <vanderwl@us.ibm.com>2016-02-23 21:38:30 +0000
commit866dfbb3af19fc4f0db7ff2605a54be95508f300 (patch)
tree28bedc165fdddfebe6069e24e8fd84ba1d8d5171
parent69ae909123f553ae07d0e3309982a0f3a973b9bc (diff)
use bind_service attribute instead of endpoints
* adapted server recipes to use the address and port defined in the bind_service attribute instead of the endpoint (endpoint can be different and should only be used by the services connecting to the db) * changed get_password 'user' to 'db' for consitency with common Depends-On: Iae7e302973805af3cb44be1b29d0e61e76eb0aa0 Implements: blueprint cookbook-refactoring Change-Id: I0afb5942c38ed4e20037f553879de8e2c1a1f75f
Notes
Notes (review): Code-Review+2: Mark Vanderwiel <vanderwl@us.ibm.com> Workflow+1: Mark Vanderwiel <vanderwl@us.ibm.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 23 Feb 2016 23:09:44 +0000 Reviewed-on: https://review.openstack.org/278875 Project: openstack/cookbook-openstack-ops-database Branch: refs/heads/master
-rw-r--r--recipes/mariadb-server.rb14
-rw-r--r--recipes/mysql-server.rb13
-rw-r--r--recipes/postgresql-server.rb9
-rw-r--r--spec/mariadb-server_spec.rb2
-rw-r--r--spec/spec_helper.rb2
5 files changed, 28 insertions, 12 deletions
diff --git a/recipes/mariadb-server.rb b/recipes/mariadb-server.rb
index 0a431a4..6120e5e 100644
--- a/recipes/mariadb-server.rb
+++ b/recipes/mariadb-server.rb
@@ -20,15 +20,21 @@ class ::Chef::Recipe # rubocop:disable Documentation
20 include ::Openstack 20 include ::Openstack
21end 21end
22 22
23db_endpoint = node['openstack']['endpoints']['db'] 23bind_db = node['openstack']['bind_service']['db']
24super_password = get_password 'user', node['openstack']['db']['root_user_key'] 24if bind_db['interface']
25 listen_address = address_for bind_db['interface']
26else
27 listen_address = bind_db['host']
28end
29
30super_password = get_password 'db', node['openstack']['db']['root_user_key']
25 31
26node.override['mariadb']['allow_root_pass_change'] = true 32node.override['mariadb']['allow_root_pass_change'] = true
27node.override['mariadb']['server_root_password'] = super_password 33node.override['mariadb']['server_root_password'] = super_password
28node.override['mariadb']['mysqld']['bind_address'] = db_endpoint.host 34node.override['mariadb']['mysqld']['bind_address'] = listen_address
29node.override['mariadb']['install']['prefer_os_package'] = true 35node.override['mariadb']['install']['prefer_os_package'] = true
30 36
31unless db_endpoint.host == '127.0.0.1' || db_endpoint.host == 'localhost' 37unless listen_address == '127.0.0.1' || listen_address == 'localhost'
32 node.override['mariadb']['forbid_remote_root'] = false 38 node.override['mariadb']['forbid_remote_root'] = false
33end 39end
34 40
diff --git a/recipes/mysql-server.rb b/recipes/mysql-server.rb
index 79e24d5..d692cd4 100644
--- a/recipes/mysql-server.rb
+++ b/recipes/mysql-server.rb
@@ -24,9 +24,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
24 include ::Openstack 24 include ::Openstack
25end 25end
26 26
27db_endpoint = node['openstack']['endpoints']['db'] 27bind_db = node['openstack']['bind_service']['db']
28if bind_db['interface']
29 listen_address = address_for bind_db['interface']
30else
31 listen_address = bind_db['host']
32end
28 33
29super_password = get_password 'user', node['openstack']['db']['root_user_key'] 34super_password = get_password 'db', node['openstack']['db']['root_user_key']
30 35
31include_recipe 'openstack-ops-database::mysql-client' 36include_recipe 'openstack-ops-database::mysql-client'
32 37
@@ -34,8 +39,8 @@ mysql_service node['openstack']['mysql']['service_name'] do
34 version node['openstack']['mysql']['version'] 39 version node['openstack']['mysql']['version']
35 data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir'] 40 data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir']
36 initial_root_password super_password 41 initial_root_password super_password
37 bind_address db_endpoint.host 42 bind_address listen_address
38 port db_endpoint.port.to_s 43 port bind_db.port.to_s
39 action [:create, :start] 44 action [:create, :start]
40end 45end
41 46
diff --git a/recipes/postgresql-server.rb b/recipes/postgresql-server.rb
index 6153237..7ab387c 100644
--- a/recipes/postgresql-server.rb
+++ b/recipes/postgresql-server.rb
@@ -25,9 +25,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
25 include ::Openstack 25 include ::Openstack
26end 26end
27 27
28db_endpoint = node['openstack']['endpoints']['db'] 28bind_db = node['openstack']['bind_service']['db']
29if bind_db['interface']
30 listen_address = address_for bind_db['interface']
31else
32 listen_address = bind_db['host']
33end
29 34
30node.override['postgresql']['config']['listen_addresses'] = db_endpoint.host 35node.override['postgresql']['config']['listen_addresses'] = listen_address
31 36
32include_recipe 'openstack-ops-database::postgresql-client' 37include_recipe 'openstack-ops-database::postgresql-client'
33include_recipe 'postgresql::server' 38include_recipe 'postgresql::server'
diff --git a/spec/mariadb-server_spec.rb b/spec/mariadb-server_spec.rb
index 08812bd..6778c23 100644
--- a/spec/mariadb-server_spec.rb
+++ b/spec/mariadb-server_spec.rb
@@ -59,7 +59,7 @@ describe 'openstack-ops-database::mariadb-server' do
59 end 59 end
60 60
61 it 'allow root remote access' do 61 it 'allow root remote access' do
62 node.set['openstack']['endpoints']['db']['host'] = '192.168.1.1' 62 node.set['openstack']['bind_service']['db']['host'] = '192.168.1.1'
63 expect(chef_run.node['mariadb']['forbid_remote_root']).to be false 63 expect(chef_run.node['mariadb']['forbid_remote_root']).to be false
64 end 64 end
65 65
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b3d5de7..8977f12 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -32,7 +32,7 @@ shared_context 'database-stubs' do
32 .with('db', anything) 32 .with('db', anything)
33 .and_return('test-pass') 33 .and_return('test-pass')
34 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 34 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
35 .with('user', 'mysqlroot') 35 .with('db', 'mysqlroot')
36 .and_return('abc123') 36 .and_return('abc123')
37 end 37 end
38end 38end