Connection params off by default but settable via hiera
This commit is contained in:
parent
4f03c6cf6b
commit
63ab89048d
4 changed files with 129 additions and 21 deletions
|
@ -28,7 +28,7 @@ class puppetdb::params inherits puppetdb::globals {
|
|||
$database_ssl = undef
|
||||
$jdbc_ssl_properties = ''
|
||||
$database_validate = true
|
||||
$database_max_pool_size = '25'
|
||||
$database_max_pool_size = undef
|
||||
|
||||
# These settings manage the various auto-deactivation and auto-purge settings
|
||||
$node_ttl = '0s'
|
||||
|
@ -58,7 +58,7 @@ class puppetdb::params inherits puppetdb::globals {
|
|||
$read_conn_max_age = '60'
|
||||
$read_conn_keep_alive = '45'
|
||||
$read_conn_lifetime = '0'
|
||||
$read_database_max_pool_size = '25'
|
||||
$read_database_max_pool_size = undef
|
||||
|
||||
$manage_firewall = true
|
||||
$java_args = {}
|
||||
|
@ -166,4 +166,13 @@ class puppetdb::params inherits puppetdb::globals {
|
|||
$certificate_whitelist = [ ]
|
||||
# change to this to only allow access by the puppet master by default:
|
||||
#$certificate_whitelist = [ $::servername ]
|
||||
|
||||
# Get the parameter name for the database connection pool tuning
|
||||
if $puppetdb_version in ['latest','present'] or versioncmp($puppetdb_version, '4.0.0') >= 0 {
|
||||
$database_max_pool_size_setting_name = 'maximum-pool-size'
|
||||
} elsif versioncmp($puppetdb_version, '3.2.0') >= 0 {
|
||||
$database_max_pool_size_setting_name = 'partition-conn-max'
|
||||
} else {
|
||||
$database_max_pool_size_setting_name = undef
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,8 +161,17 @@ class puppetdb::server::database (
|
|||
value => $conn_lifetime,
|
||||
}
|
||||
|
||||
ini_setting { 'puppetdb_database_max_pool_size':
|
||||
setting => 'maximum-pool-size',
|
||||
value => $database_max_pool_size,
|
||||
if $puppetdb::params::database_max_pool_size_setting_name != undef {
|
||||
if $database_max_pool_size == 'absent' {
|
||||
ini_setting { 'puppetdb_database_max_pool_size':
|
||||
ensure => absent,
|
||||
setting => $puppetdb::params::database_max_pool_size_setting_name,
|
||||
}
|
||||
} elsif $database_max_pool_size != undef {
|
||||
ini_setting { 'puppetdb_database_max_pool_size':
|
||||
setting => $puppetdb::params::database_max_pool_size_setting_name,
|
||||
value => $database_max_pool_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,20 @@ class puppetdb::server::read_database (
|
|||
setting => 'conn-lifetime',
|
||||
value => $conn_lifetime,
|
||||
}
|
||||
|
||||
if $puppetdb::params::database_max_pool_size_setting_name != undef {
|
||||
if $database_max_pool_size == 'absent' {
|
||||
ini_setting { 'puppetdb_read_database_max_pool_size':
|
||||
ensure => absent,
|
||||
setting => $puppetdb::params::database_max_pool_size_setting_name,
|
||||
}
|
||||
} elsif $database_max_pool_size != undef {
|
||||
ini_setting { 'puppetdb_read_database_max_pool_size':
|
||||
setting => $puppetdb::params::database_max_pool_size_setting_name,
|
||||
value => $database_max_pool_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
file { "${confdir}/read_database.ini":
|
||||
ensure => absent,
|
||||
|
|
|
@ -125,14 +125,7 @@ describe 'puppetdb::server::database', :type => :class do
|
|||
'setting' => 'conn-lifetime',
|
||||
'value' => '0'
|
||||
)}
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'present',
|
||||
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'maximum-pool-size',
|
||||
'value' => '25'
|
||||
)}
|
||||
it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
|
||||
end
|
||||
|
||||
describe 'when using a legacy PuppetDB version' do
|
||||
|
@ -241,14 +234,7 @@ describe 'puppetdb::server::database', :type => :class do
|
|||
'setting' => 'conn-lifetime',
|
||||
'value' => '0'
|
||||
)}
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'present',
|
||||
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'maximum-pool-size',
|
||||
'value' => '25'
|
||||
)}
|
||||
it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
|
||||
end
|
||||
|
||||
describe 'when overriding database_path for embedded' do
|
||||
|
@ -267,5 +253,95 @@ describe 'puppetdb::server::database', :type => :class do
|
|||
'value' => 'file:/tmp/foo;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'when setting max pool size' do
|
||||
context 'on current PuppetDB' do
|
||||
describe 'to a numeric value' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 12345
|
||||
}
|
||||
end
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'present',
|
||||
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'maximum-pool-size',
|
||||
'value' => '12345'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'to absent' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 'absent'
|
||||
}
|
||||
end
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'absent',
|
||||
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'maximum-pool-size'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
context 'on PuppetDB 3.2' do
|
||||
let (:pre_condition) { 'class { "puppetdb::globals": version => "3.2.0", }' }
|
||||
describe 'to a numeric value' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 12345
|
||||
}
|
||||
end
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'present',
|
||||
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'partition-conn-max',
|
||||
'value' => '12345'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'to absent' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 'absent'
|
||||
}
|
||||
end
|
||||
it { should contain_ini_setting('puppetdb_database_max_pool_size').
|
||||
with(
|
||||
'ensure' => 'absent',
|
||||
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
|
||||
'section' => 'database',
|
||||
'setting' => 'partition-conn-max'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
context 'on a legacy PuppetDB version' do
|
||||
let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
|
||||
describe 'to a numeric value' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 12345
|
||||
}
|
||||
end
|
||||
it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
|
||||
end
|
||||
|
||||
describe 'to absent' do
|
||||
let(:params) do
|
||||
{
|
||||
'database_max_pool_size': 'absent'
|
||||
}
|
||||
end
|
||||
it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue