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: I2ca8100d1c4d0a8053e403c5ba6d3c2939b63af6
This commit is contained in:
Takashi Kajinami 2020-05-19 20:06:56 +09:00
parent e820f97ac1
commit 33057eb12d
8 changed files with 63 additions and 61 deletions

View File

@ -58,7 +58,7 @@ class ironic::db::mysql (
::openstacklib::db::mysql { 'ironic':
user => $user,
password_hash => mysql::password($password),
password => $password,
dbname => $dbname,
host => $host,
charset => $charset,

View File

@ -35,11 +35,11 @@ class ironic::db::postgresql(
include ironic::deps
::openstacklib::db::postgresql { 'ironic':
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['ironic::db::begin']

View File

@ -56,7 +56,7 @@ class ironic::inspector::db::mysql (
::openstacklib::db::mysql { 'ironic-inspector':
user => $user,
password_hash => mysql::password($password),
password => $password,
dbname => $dbname,
host => $host,
charset => $charset,

View File

@ -35,11 +35,11 @@ class ironic::inspector::db::postgresql(
Class['ironic::inspector::db::postgresql'] -> Service<| title == 'ironic-inspector' |>
::openstacklib::db::postgresql { 'ironic-inspector':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
password => $password,
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['ironic-inspector'] ~> Exec<| title == 'ironic-inspector-dbsync' |>

View File

@ -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": "puppetlabs/stdlib",
"version_requirement": ">=5.0.0 <7.0.0"

View File

@ -27,7 +27,43 @@ describe 'ironic::db::mysql' do
end
let :params do
{ :password => 'passw0rd' }
{ :password => 'ironicpass' }
end
shared_examples_for 'ironic::db::mysql' do
context 'with only required params' do
it { is_expected.to contain_openstacklib__db__mysql('ironic').with(
:user => 'ironic',
:password => 'ironicpass',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
context "overriding allowed_hosts param to array" do
let :params do
{
:allowed_hosts => ['127.0.0.1','%']
}
end
end
context "overriding allowed_hosts param to string" do
let :params do
{
:allowed_hosts => '192.168.1.1'
}
end
end
context "overriding allowed_hosts param equals to host param " do
let :params do
{
:allowed_hosts => '127.0.0.1'
}
end
end
end
on_supported_os({
@ -38,40 +74,8 @@ describe 'ironic::db::mysql' do
facts.merge!(OSDefaults.get_facts())
end
it { is_expected.to contain_openstacklib__db__mysql('ironic').with(
:user => 'ironic',
:password_hash => '*74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
it_behaves_like 'ironic::db::mysql'
end
end
describe "overriding allowed_hosts param to array" do
let :params do
{
:allowed_hosts => ['127.0.0.1','%']
}
end
end
describe "overriding allowed_hosts param to string" do
let :params do
{
:allowed_hosts => '192.168.1.1'
}
end
end
describe "overriding allowed_hosts param equals to host param " do
let :params do
{
:allowed_hosts => '127.0.0.1'
}
end
end
end

View File

@ -24,7 +24,7 @@ describe 'ironic::inspector::db::mysql' do
shared_examples_for 'ironic::inspector::db::mysql' do
let :req_params do
{ :password => 'passw0rd' }
{ :password => 'ironicpass' }
end
let :pre_condition do
@ -37,10 +37,10 @@ describe 'ironic::inspector::db::mysql' do
end
it { is_expected.to contain_openstacklib__db__mysql('ironic-inspector').with(
:user => 'ironic-inspector',
:password_hash => '*74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:user => 'ironic-inspector',
:password => 'ironicpass',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end

View File

@ -4,7 +4,7 @@ describe 'ironic::inspector::db::postgresql' do
shared_examples_for 'ironic::inspector::db::postgresql' do
let :req_params do
{ :password => 'pw' }
{ :password => 'ironicpass' }
end
let :pre_condition do
@ -16,12 +16,14 @@ describe 'ironic::inspector::db::postgresql' do
req_params
end
it { is_expected.to contain_postgresql__server__db('ironic-inspector').with(
:user => 'ironic-inspector',
:password => 'md5f4da35e834f32b2deceef0dcd269e195'
it { is_expected.to contain_openstacklib__db__postgresql('ironic-inspector').with(
:user => 'ironic-inspector',
:password => 'ironicpass',
:dbname => 'ironic-inspector',
:encoding => nil,
:privileges => 'ALL',
)}
end
end
on_supported_os({