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
This commit is contained in:
parent
69ae909123
commit
866dfbb3af
|
@ -20,15 +20,21 @@ class ::Chef::Recipe # rubocop:disable Documentation
|
||||||
include ::Openstack
|
include ::Openstack
|
||||||
end
|
end
|
||||||
|
|
||||||
db_endpoint = node['openstack']['endpoints']['db']
|
bind_db = node['openstack']['bind_service']['db']
|
||||||
super_password = get_password 'user', node['openstack']['db']['root_user_key']
|
if bind_db['interface']
|
||||||
|
listen_address = address_for bind_db['interface']
|
||||||
|
else
|
||||||
|
listen_address = bind_db['host']
|
||||||
|
end
|
||||||
|
|
||||||
|
super_password = get_password 'db', node['openstack']['db']['root_user_key']
|
||||||
|
|
||||||
node.override['mariadb']['allow_root_pass_change'] = true
|
node.override['mariadb']['allow_root_pass_change'] = true
|
||||||
node.override['mariadb']['server_root_password'] = super_password
|
node.override['mariadb']['server_root_password'] = super_password
|
||||||
node.override['mariadb']['mysqld']['bind_address'] = db_endpoint.host
|
node.override['mariadb']['mysqld']['bind_address'] = listen_address
|
||||||
node.override['mariadb']['install']['prefer_os_package'] = true
|
node.override['mariadb']['install']['prefer_os_package'] = true
|
||||||
|
|
||||||
unless db_endpoint.host == '127.0.0.1' || db_endpoint.host == 'localhost'
|
unless listen_address == '127.0.0.1' || listen_address == 'localhost'
|
||||||
node.override['mariadb']['forbid_remote_root'] = false
|
node.override['mariadb']['forbid_remote_root'] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
|
||||||
include ::Openstack
|
include ::Openstack
|
||||||
end
|
end
|
||||||
|
|
||||||
db_endpoint = node['openstack']['endpoints']['db']
|
bind_db = node['openstack']['bind_service']['db']
|
||||||
|
if bind_db['interface']
|
||||||
|
listen_address = address_for bind_db['interface']
|
||||||
|
else
|
||||||
|
listen_address = bind_db['host']
|
||||||
|
end
|
||||||
|
|
||||||
super_password = get_password 'user', node['openstack']['db']['root_user_key']
|
super_password = get_password 'db', node['openstack']['db']['root_user_key']
|
||||||
|
|
||||||
include_recipe 'openstack-ops-database::mysql-client'
|
include_recipe 'openstack-ops-database::mysql-client'
|
||||||
|
|
||||||
|
@ -34,8 +39,8 @@ mysql_service node['openstack']['mysql']['service_name'] do
|
||||||
version node['openstack']['mysql']['version']
|
version node['openstack']['mysql']['version']
|
||||||
data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir']
|
data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir']
|
||||||
initial_root_password super_password
|
initial_root_password super_password
|
||||||
bind_address db_endpoint.host
|
bind_address listen_address
|
||||||
port db_endpoint.port.to_s
|
port bind_db.port.to_s
|
||||||
action [:create, :start]
|
action [:create, :start]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
|
||||||
include ::Openstack
|
include ::Openstack
|
||||||
end
|
end
|
||||||
|
|
||||||
db_endpoint = node['openstack']['endpoints']['db']
|
bind_db = node['openstack']['bind_service']['db']
|
||||||
|
if bind_db['interface']
|
||||||
|
listen_address = address_for bind_db['interface']
|
||||||
|
else
|
||||||
|
listen_address = bind_db['host']
|
||||||
|
end
|
||||||
|
|
||||||
node.override['postgresql']['config']['listen_addresses'] = db_endpoint.host
|
node.override['postgresql']['config']['listen_addresses'] = listen_address
|
||||||
|
|
||||||
include_recipe 'openstack-ops-database::postgresql-client'
|
include_recipe 'openstack-ops-database::postgresql-client'
|
||||||
include_recipe 'postgresql::server'
|
include_recipe 'postgresql::server'
|
||||||
|
|
|
@ -59,7 +59,7 @@ describe 'openstack-ops-database::mariadb-server' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allow root remote access' do
|
it 'allow root remote access' do
|
||||||
node.set['openstack']['endpoints']['db']['host'] = '192.168.1.1'
|
node.set['openstack']['bind_service']['db']['host'] = '192.168.1.1'
|
||||||
expect(chef_run.node['mariadb']['forbid_remote_root']).to be false
|
expect(chef_run.node['mariadb']['forbid_remote_root']).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ shared_context 'database-stubs' do
|
||||||
.with('db', anything)
|
.with('db', anything)
|
||||||
.and_return('test-pass')
|
.and_return('test-pass')
|
||||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||||
.with('user', 'mysqlroot')
|
.with('db', 'mysqlroot')
|
||||||
.and_return('abc123')
|
.and_return('abc123')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue