From ce663a7718548ffea74b29dbb756018293c5c4af Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 20 May 2020 08:35:22 +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: I96f0496889fe6fa349259689f2a46ac5e029c46d --- manifests/db/mysql.pp | 2 +- manifests/db/postgresql.pp | 10 +++--- metadata.json | 4 --- spec/classes/watcher_db_mysql_spec.rb | 42 +++++++++++----------- spec/classes/watcher_db_postgresql_spec.rb | 11 +++--- 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index eaeb8bf..ad72a25 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -49,7 +49,7 @@ class watcher::db::mysql( ::openstacklib::db::mysql { 'watcher': 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 75d473e..9236dca 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -35,11 +35,11 @@ class watcher::db::postgresql( include watcher::deps ::openstacklib::db::postgresql { 'watcher': - 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['watcher::db::begin'] diff --git a/metadata.json b/metadata.json index 5bbeaa1..0c4a172 100644 --- a/metadata.json +++ b/metadata.json @@ -13,10 +13,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/watcher_db_mysql_spec.rb b/spec/classes/watcher_db_mysql_spec.rb index 545307d..14bd007 100644 --- a/spec/classes/watcher_db_mysql_spec.rb +++ b/spec/classes/watcher_db_mysql_spec.rb @@ -7,7 +7,7 @@ describe 'watcher::db::mysql' do end let :required_params do - { :password => 'fooboozoo_default_password', } + { :password => 'watcherpass', } end shared_examples_for 'watcher-db-mysql' do @@ -17,12 +17,12 @@ describe 'watcher::db::mysql' do end it { is_expected.to contain_openstacklib__db__mysql('watcher').with( - :user => 'watcher', - :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206', - :dbname => 'watcher', - :host => '127.0.0.1', - :charset => 'utf8', - :collate => 'utf8_general_ci', + :user => 'watcher', + :password => 'watcherpass', + :dbname => 'watcher', + :host => '127.0.0.1', + :charset => 'utf8', + :collate => 'utf8_general_ci', )} end @@ -32,13 +32,13 @@ describe 'watcher::db::mysql' do end it { is_expected.to contain_openstacklib__db__mysql('watcher').with( - :user => 'watcher', - :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206', - :dbname => 'watcher', - :host => '127.0.0.1', - :charset => 'utf8', - :collate => 'utf8_general_ci', - :allowed_hosts => ['127.0.0.1','%'] + :user => 'watcher', + :password => 'watcherpass', + :dbname => 'watcher', + :host => '127.0.0.1', + :charset => 'utf8', + :collate => 'utf8_general_ci', + :allowed_hosts => ['127.0.0.1','%'] )} end @@ -48,13 +48,13 @@ describe 'watcher::db::mysql' do end it { is_expected.to contain_openstacklib__db__mysql('watcher').with( - :user => 'watcher', - :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206', - :dbname => 'watcher', - :host => '127.0.0.1', - :charset => 'utf8', - :collate => 'utf8_general_ci', - :allowed_hosts => '192.168.1.1' + :user => 'watcher', + :password => 'watcherpass', + :dbname => 'watcher', + :host => '127.0.0.1', + :charset => 'utf8', + :collate => 'utf8_general_ci', + :allowed_hosts => '192.168.1.1' )} end end diff --git a/spec/classes/watcher_db_postgresql_spec.rb b/spec/classes/watcher_db_postgresql_spec.rb index de26cd3..a19f468 100644 --- a/spec/classes/watcher_db_postgresql_spec.rb +++ b/spec/classes/watcher_db_postgresql_spec.rb @@ -7,7 +7,7 @@ describe 'watcher::db::postgresql' do end let :required_params do - { :password => 'pw' } + { :password => 'watcherpass' } end shared_examples_for 'watcher-db-postgresql' do @@ -16,9 +16,12 @@ describe 'watcher::db::postgresql' do required_params end - it { is_expected.to contain_postgresql__server__db('watcher').with( - :user => 'watcher', - :password => 'md5bb8678c96047fcce9b899ad5da021642' + it { is_expected.to contain_openstacklib__db__postgresql('watcher').with( + :user => 'watcher', + :password => 'watcherpass', + :dbname => 'watcher', + :encoding => nil, + :privileges => 'ALL', )} end end