From 8a733cddad286a444bfe546e2bf98f7f5d48ae93 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 19 May 2020 21:51:56 +0900 Subject: [PATCH] Remove password hash generation in each puppet modules ... and migrate it to openstacklib so that all logics about database configuration are implemented in one common place. Depends-on: https://review.opendev.org/#/c/728595/ Change-Id: I952e990e1f56d6e0226eac25397ab3062074551f --- manifests/db/mysql.pp | 2 +- manifests/db/postgresql.pp | 10 +++++----- metadata.json | 4 ---- spec/classes/trove_db_mysql_spec.rb | 20 ++++++++++---------- spec/classes/trove_db_postgresql_spec.rb | 11 +++++++---- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 2ec57851..e93cd72f 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -65,7 +65,7 @@ class trove::db::mysql( ::openstacklib::db::mysql { 'trove': user => $user, - password_hash => mysql::password($password), + password => $password, dbname => $dbname, host => $host, charset => $charset, diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index 344d244f..934d0924 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -37,11 +37,11 @@ class trove::db::postgresql( validate_legacy(String, 'validate_string', $password) ::openstacklib::db::postgresql { 'trove': - password_hash => postgresql_password($user, $password), - dbname => $dbname, - user => $user, - encoding => $encoding, - privileges => $privileges, + password => $password, + dbname => $dbname, + user => $user, + encoding => $encoding, + privileges => $privileges, } Anchor['trove::db::begin'] diff --git a/metadata.json b/metadata.json index 9b881f85..d60c8bdf 100644 --- a/metadata.json +++ b/metadata.json @@ -17,10 +17,6 @@ "name": "puppet/rabbitmq", "version_requirement": ">=8.4.0 <11.0.0" }, - { - "name": "puppetlabs/mysql", - "version_requirement": ">=6.0.0 <11.0.0" - }, { "name": "openstack/openstacklib", "version_requirement": ">=16.3.0 <17.0.0" diff --git a/spec/classes/trove_db_mysql_spec.rb b/spec/classes/trove_db_mysql_spec.rb index 0859e06b..42f01fd1 100644 --- a/spec/classes/trove_db_mysql_spec.rb +++ b/spec/classes/trove_db_mysql_spec.rb @@ -27,12 +27,12 @@ describe 'trove::db::mysql' do end let :params do - { :dbname => 'trove', - :password => 's3cr3t', - :user => 'trove', - :charset => 'utf8', - :collate => 'utf8_general_ci', - :host => '127.0.0.1', + { :dbname => 'trove', + :password => 'trovepass', + :user => 'trove', + :charset => 'utf8', + :collate => 'utf8_general_ci', + :host => '127.0.0.1', } end @@ -47,7 +47,7 @@ describe 'trove::db::mysql' do is_expected.to contain_openstacklib__db__mysql('trove').with( :user => params[:user], :dbname => params[:dbname], - :password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0', + :password => params[:password], :host => params[:host], :charset => params[:charset] ) @@ -56,7 +56,7 @@ describe 'trove::db::mysql' do context 'overriding allowed_hosts param to array' do before :each do params.merge!( - :allowed_hosts => ['127.0.0.1','%'] + :allowed_hosts => ['127.0.0.1','%'] ) end @@ -64,7 +64,7 @@ describe 'trove::db::mysql' do is_expected.to contain_openstacklib__db__mysql('trove').with( :user => params[:user], :dbname => params[:dbname], - :password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0', + :password => params[:password], :host => params[:host], :charset => params[:charset], :allowed_hosts => ['127.0.0.1','%'] @@ -82,7 +82,7 @@ describe 'trove::db::mysql' do is_expected.to contain_openstacklib__db__mysql('trove').with( :user => params[:user], :dbname => params[:dbname], - :password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0', + :password => params[:password], :host => params[:host], :charset => params[:charset], :allowed_hosts => '192.168.1.1' diff --git a/spec/classes/trove_db_postgresql_spec.rb b/spec/classes/trove_db_postgresql_spec.rb index f413fe6b..3f08c1e7 100644 --- a/spec/classes/trove_db_postgresql_spec.rb +++ b/spec/classes/trove_db_postgresql_spec.rb @@ -4,7 +4,7 @@ describe 'trove::db::postgresql' do shared_examples_for 'trove::db::postgresql' do let :req_params do - { :password => 'pw' } + { :password => 'trovepass' } end let :pre_condition do @@ -16,9 +16,12 @@ describe 'trove::db::postgresql' do req_params end - it { is_expected.to contain_postgresql__server__db('trove').with( - :user => 'trove', - :password => 'md5e12ef276d200761a0808f17a5b076451' + it { is_expected.to contain_openstacklib__db__postgresql('trove').with( + :user => 'trove', + :password => 'trovepass', + :dbname => 'trove', + :encoding => nil, + :privileges => 'ALL', )} end