Browse Source

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
tags/mitaka-eol
Jan Klare 3 years ago
parent
commit
866dfbb3af

+ 10
- 4
recipes/mariadb-server.rb View File

@@ -20,15 +20,21 @@ class ::Chef::Recipe # rubocop:disable Documentation
20 20
   include ::Openstack
21 21
 end
22 22
 
23
-db_endpoint = node['openstack']['endpoints']['db']
24
-super_password = get_password 'user', node['openstack']['db']['root_user_key']
23
+bind_db = node['openstack']['bind_service']['db']
24
+if bind_db['interface']
25
+  listen_address = address_for bind_db['interface']
26
+else
27
+  listen_address = bind_db['host']
28
+end
29
+
30
+super_password = get_password 'db', node['openstack']['db']['root_user_key']
25 31
 
26 32
 node.override['mariadb']['allow_root_pass_change'] = true
27 33
 node.override['mariadb']['server_root_password'] = super_password
28
-node.override['mariadb']['mysqld']['bind_address'] = db_endpoint.host
34
+node.override['mariadb']['mysqld']['bind_address'] = listen_address
29 35
 node.override['mariadb']['install']['prefer_os_package'] = true
30 36
 
31
-unless db_endpoint.host == '127.0.0.1' || db_endpoint.host == 'localhost'
37
+unless listen_address == '127.0.0.1' || listen_address == 'localhost'
32 38
   node.override['mariadb']['forbid_remote_root'] = false
33 39
 end
34 40
 

+ 9
- 4
recipes/mysql-server.rb View File

@@ -24,9 +24,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
24 24
   include ::Openstack
25 25
 end
26 26
 
27
-db_endpoint = node['openstack']['endpoints']['db']
27
+bind_db = node['openstack']['bind_service']['db']
28
+if bind_db['interface']
29
+  listen_address = address_for bind_db['interface']
30
+else
31
+  listen_address = bind_db['host']
32
+end
28 33
 
29
-super_password = get_password 'user', node['openstack']['db']['root_user_key']
34
+super_password = get_password 'db', node['openstack']['db']['root_user_key']
30 35
 
31 36
 include_recipe 'openstack-ops-database::mysql-client'
32 37
 
@@ -34,8 +39,8 @@ mysql_service node['openstack']['mysql']['service_name'] do
34 39
   version node['openstack']['mysql']['version']
35 40
   data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir']
36 41
   initial_root_password super_password
37
-  bind_address db_endpoint.host
38
-  port db_endpoint.port.to_s
42
+  bind_address listen_address
43
+  port bind_db.port.to_s
39 44
   action [:create, :start]
40 45
 end
41 46
 

+ 7
- 2
recipes/postgresql-server.rb View File

@@ -25,9 +25,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
25 25
   include ::Openstack
26 26
 end
27 27
 
28
-db_endpoint = node['openstack']['endpoints']['db']
28
+bind_db = node['openstack']['bind_service']['db']
29
+if bind_db['interface']
30
+  listen_address = address_for bind_db['interface']
31
+else
32
+  listen_address = bind_db['host']
33
+end
29 34
 
30
-node.override['postgresql']['config']['listen_addresses'] = db_endpoint.host
35
+node.override['postgresql']['config']['listen_addresses'] = listen_address
31 36
 
32 37
 include_recipe 'openstack-ops-database::postgresql-client'
33 38
 include_recipe 'postgresql::server'

+ 1
- 1
spec/mariadb-server_spec.rb View File

@@ -59,7 +59,7 @@ describe 'openstack-ops-database::mariadb-server' do
59 59
     end
60 60
 
61 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 63
       expect(chef_run.node['mariadb']['forbid_remote_root']).to be false
64 64
     end
65 65
 

+ 1
- 1
spec/spec_helper.rb View File

@@ -32,7 +32,7 @@ shared_context 'database-stubs' do
32 32
       .with('db', anything)
33 33
       .and_return('test-pass')
34 34
     allow_any_instance_of(Chef::Recipe).to receive(:get_password)
35
-      .with('user', 'mysqlroot')
35
+      .with('db', 'mysqlroot')
36 36
       .and_return('abc123')
37 37
   end
38 38
 end

Loading…
Cancel
Save