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 include ::Openstack end -db_endpoint = node['openstack']['endpoints']['db'] -super_password = get_password 'user', node['openstack']['db']['root_user_key'] +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 'db', node['openstack']['db']['root_user_key'] node.override['mariadb']['allow_root_pass_change'] = true 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 -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 end 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 include ::Openstack 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' @@ -34,8 +39,8 @@ mysql_service node['openstack']['mysql']['service_name'] do version node['openstack']['mysql']['version'] data_dir node['openstack']['mysql']['data_dir'] if node['openstack']['mysql']['data_dir'] initial_root_password super_password - bind_address db_endpoint.host - port db_endpoint.port.to_s + bind_address listen_address + port bind_db.port.to_s action [:create, :start] end 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 include ::Openstack 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 '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 end 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 end 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 .with('db', anything) .and_return('test-pass') allow_any_instance_of(Chef::Recipe).to receive(:get_password) - .with('user', 'mysqlroot') + .with('db', 'mysqlroot') .and_return('abc123') end end