Update allowed_hosts conditional statement
In the origin cinder::db::mysql, if the value of $allowed_hosts contains or equals to $host, then puppet will complain duplicate declaration error. This patch is aim to update the allowed_hosts conditonal statement in cinder::db::mysql. There are two cases to pass $allowed_hosts to $real_allowed_hosts: - If $allowed_hosts is array,then remove $host from $allowed_hosts; - elsif $allowed_hosts is string and not equivalent to $host; At last, if $real_allowed_hosts is not undef, then run cinder::db::mysql::host_access Fix bug 1206444 Change-Id: I7eb9d883c1617d9913899f32ef47a892c1d9a1a2
This commit is contained in:
parent
0b6937bddf
commit
e7657de5ba
@ -20,9 +20,16 @@ class cinder::db::mysql (
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
|
||||
if $allowed_hosts {
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
||||
$real_allowed_hosts = delete($allowed_hosts,$host)
|
||||
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
|
||||
$real_allowed_hosts = $allowed_hosts
|
||||
}
|
||||
|
||||
if $real_allowed_hosts {
|
||||
# TODO this class should be in the mysql namespace
|
||||
cinder::db::mysql::host_access { $allowed_hosts:
|
||||
cinder::db::mysql::host_access { $real_allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
|
@ -25,4 +25,52 @@ describe 'cinder::db::mysql' do
|
||||
:charset => 'latin1'
|
||||
) }
|
||||
end
|
||||
describe "overriding allowed_hosts param to array" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'cinderpass',
|
||||
:allowed_hosts => ['127.0.0.1','%']
|
||||
}
|
||||
end
|
||||
|
||||
it {should_not contain_cinder__db__mysql__host_access("127.0.0.1").with(
|
||||
:user => 'cinder',
|
||||
:password => 'cinderpass',
|
||||
:database => 'cinder'
|
||||
)}
|
||||
it {should contain_cinder__db__mysql__host_access("%").with(
|
||||
:user => 'cinder',
|
||||
:password => 'cinderpass',
|
||||
:database => 'cinder'
|
||||
)}
|
||||
end
|
||||
describe "overriding allowed_hosts param to string" do
|
||||
let :params do
|
||||
{
|
||||
:password => 'cinderpass2',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
}
|
||||
end
|
||||
|
||||
it {should contain_cinder__db__mysql__host_access("192.168.1.1").with(
|
||||
:user => 'cinder',
|
||||
:password => 'cinderpass2',
|
||||
:database => 'cinder'
|
||||
)}
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param equals to host param " do
|
||||
let :params do
|
||||
{
|
||||
:password => 'cinderpass2',
|
||||
:allowed_hosts => '127.0.0.1'
|
||||
}
|
||||
end
|
||||
|
||||
it {should_not contain_cinder__db__mysql__host_access("127.0.0.1").with(
|
||||
:user => 'cinder',
|
||||
:password => 'cinderpass2',
|
||||
:database => 'cinder'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user