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:
Jan Klare 2016-02-11 07:37:11 +01:00 committed by Mark Vanderwiel
parent 69ae909123
commit 866dfbb3af
5 changed files with 28 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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