Merge pull request #185 from kbarber/ticket/stable/pdb-1455-allow-custom-embedded-subname
(PDB-1455) Provide mechanism for modifying default HSQLDB path
This commit is contained in:
commit
7577699003
6 changed files with 205 additions and 56 deletions
|
@ -257,6 +257,10 @@ Setting up proper trust- and keystores has to be managed outside of the puppetdb
|
||||||
|
|
||||||
If true, the module will attempt to connect to the database using the specified settings and fail if it is not able to do so. (defaults to true)
|
If true, the module will attempt to connect to the database using the specified settings and fail if it is not able to do so. (defaults to true)
|
||||||
|
|
||||||
|
####`database_embedded_path`
|
||||||
|
|
||||||
|
*Embedded Database Only* Changes the path location for the HSQLDB database. Does not provide migration for old data, so if you change this value and you have an existing database you will need to manually move the content also. (defaults to package default for 2.x release).
|
||||||
|
|
||||||
####`node_ttl`
|
####`node_ttl`
|
||||||
|
|
||||||
The length of time a node can go without receiving any new data before it's automatically deactivated. (defaults to '0', which disables auto-deactivation). This option is supported in PuppetDB >= 1.1.0.
|
The length of time a node can go without receiving any new data before it's automatically deactivated. (defaults to '0', which disables auto-deactivation). This option is supported in PuppetDB >= 1.1.0.
|
||||||
|
|
|
@ -30,6 +30,7 @@ class puppetdb (
|
||||||
$database_ssl = $puppetdb::params::database_ssl,
|
$database_ssl = $puppetdb::params::database_ssl,
|
||||||
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
|
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
|
||||||
$database_validate = $puppetdb::params::database_validate,
|
$database_validate = $puppetdb::params::database_validate,
|
||||||
|
$database_embedded_path = $puppetdb::params::database_embedded_path,
|
||||||
$node_ttl = $puppetdb::params::node_ttl,
|
$node_ttl = $puppetdb::params::node_ttl,
|
||||||
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
||||||
$report_ttl = $puppetdb::params::report_ttl,
|
$report_ttl = $puppetdb::params::report_ttl,
|
||||||
|
@ -91,6 +92,7 @@ class puppetdb (
|
||||||
database_name => $database_name,
|
database_name => $database_name,
|
||||||
database_ssl => $database_ssl,
|
database_ssl => $database_ssl,
|
||||||
database_validate => $database_validate,
|
database_validate => $database_validate,
|
||||||
|
database_embedded_path => $database_embedded_path,
|
||||||
node_ttl => $node_ttl,
|
node_ttl => $node_ttl,
|
||||||
node_purge_ttl => $node_purge_ttl,
|
node_purge_ttl => $node_purge_ttl,
|
||||||
report_ttl => $report_ttl,
|
report_ttl => $report_ttl,
|
||||||
|
|
|
@ -69,52 +69,52 @@ class puppetdb::params {
|
||||||
|
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat', 'Suse', 'Archlinux': {
|
'RedHat', 'Suse', 'Archlinux': {
|
||||||
$confdir = '/etc/puppetdb/conf.d'
|
$confdir = '/etc/puppetdb/conf.d'
|
||||||
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
$database_embedded_path = '/var/lib/puppetdb/db/db'
|
||||||
$puppetdb_initconf = '/etc/sysconfig/puppetdb'
|
$puppetdb_initconf = '/etc/sysconfig/puppetdb'
|
||||||
if $settings::confdir != undef {
|
if $settings::confdir != undef {
|
||||||
$puppet_confdir = $settings::confdir
|
$puppet_confdir = $settings::confdir
|
||||||
} else {
|
} else {
|
||||||
$puppet_confdir = '/etc/puppet'
|
$puppet_confdir = '/etc/puppet'
|
||||||
}
|
}
|
||||||
$puppet_service_name = 'puppetmaster'
|
$puppet_service_name = 'puppetmaster'
|
||||||
$ssl_dir = '/etc/puppetdb/ssl'
|
$ssl_dir = '/etc/puppetdb/ssl'
|
||||||
}
|
}
|
||||||
'Debian': {
|
'Debian': {
|
||||||
$confdir = '/etc/puppetdb/conf.d'
|
$confdir = '/etc/puppetdb/conf.d'
|
||||||
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
$database_embedded_path = '/var/lib/puppetdb/db/db'
|
||||||
$puppetdb_initconf = '/etc/default/puppetdb'
|
$puppetdb_initconf = '/etc/default/puppetdb'
|
||||||
if $settings::confdir != undef {
|
if $settings::confdir != undef {
|
||||||
$puppet_confdir = $settings::confdir
|
$puppet_confdir = $settings::confdir
|
||||||
} else {
|
} else {
|
||||||
$puppet_confdir = '/etc/puppet'
|
$puppet_confdir = '/etc/puppet'
|
||||||
}
|
}
|
||||||
$puppet_service_name = 'puppetmaster'
|
$puppet_service_name = 'puppetmaster'
|
||||||
$ssl_dir = '/etc/puppetdb/ssl'
|
$ssl_dir = '/etc/puppetdb/ssl'
|
||||||
}
|
}
|
||||||
'OpenBSD': {
|
'OpenBSD': {
|
||||||
$confdir = '/etc/puppetdb/conf.d'
|
$confdir = '/etc/puppetdb/conf.d'
|
||||||
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
$database_embedded_path = '/var/db/puppetdb/db/db'
|
||||||
$puppetdb_initconf = undef
|
$puppetdb_initconf = undef
|
||||||
if $settings::confdir != undef {
|
if $settings::confdir != undef {
|
||||||
$puppet_confdir = $settings::confdir
|
$puppet_confdir = $settings::confdir
|
||||||
} else {
|
} else {
|
||||||
$puppet_confdir = '/etc/puppet'
|
$puppet_confdir = '/etc/puppet'
|
||||||
}
|
}
|
||||||
$puppet_service_name = 'puppetmasterd'
|
$puppet_service_name = 'puppetmasterd'
|
||||||
$ssl_dir = '/etc/puppetdb/ssl'
|
$ssl_dir = '/etc/puppetdb/ssl'
|
||||||
}
|
}
|
||||||
'FreeBSD': {
|
'FreeBSD': {
|
||||||
$confdir = '/usr/local/etc/puppetdb/conf.d'
|
$confdir = '/usr/local/etc/puppetdb/conf.d'
|
||||||
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
$database_embedded_path = '/var/db/puppetdb/db/db'
|
||||||
$puppetdb_initconf = undef
|
$puppetdb_initconf = undef
|
||||||
if $settings::confdir != undef {
|
if $settings::confdir != undef {
|
||||||
$puppet_confdir = $settings::confdir
|
$puppet_confdir = $settings::confdir
|
||||||
} else {
|
} else {
|
||||||
$puppet_confdir = '/usr/local/etc/puppet'
|
$puppet_confdir = '/usr/local/etc/puppet'
|
||||||
}
|
}
|
||||||
$puppet_service_name = 'puppetmaster'
|
$puppet_service_name = 'puppetmaster'
|
||||||
$ssl_dir = '/usr/local/etc/puppetdb/ssl'
|
$ssl_dir = '/usr/local/etc/puppetdb/ssl'
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
fail("${module_name} does not support your osfamily ${::osfamily}")
|
fail("${module_name} does not support your osfamily ${::osfamily}")
|
||||||
|
|
|
@ -25,6 +25,7 @@ class puppetdb::server (
|
||||||
$database_name = $puppetdb::params::database_name,
|
$database_name = $puppetdb::params::database_name,
|
||||||
$database_ssl = $puppetdb::params::database_ssl,
|
$database_ssl = $puppetdb::params::database_ssl,
|
||||||
$database_validate = $puppetdb::params::database_validate,
|
$database_validate = $puppetdb::params::database_validate,
|
||||||
|
$database_embedded_path = $puppetdb::params::database_embedded_path,
|
||||||
$node_ttl = $puppetdb::params::node_ttl,
|
$node_ttl = $puppetdb::params::node_ttl,
|
||||||
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
||||||
$report_ttl = $puppetdb::params::report_ttl,
|
$report_ttl = $puppetdb::params::report_ttl,
|
||||||
|
@ -128,24 +129,25 @@ class puppetdb::server (
|
||||||
}
|
}
|
||||||
|
|
||||||
class { 'puppetdb::server::database_ini':
|
class { 'puppetdb::server::database_ini':
|
||||||
database => $database,
|
database => $database,
|
||||||
database_host => $database_host,
|
database_host => $database_host,
|
||||||
database_port => $database_port,
|
database_port => $database_port,
|
||||||
database_username => $database_username,
|
database_username => $database_username,
|
||||||
database_password => $database_password,
|
database_password => $database_password,
|
||||||
database_name => $database_name,
|
database_name => $database_name,
|
||||||
database_ssl => $database_ssl,
|
database_ssl => $database_ssl,
|
||||||
database_validate => $database_validate,
|
database_validate => $database_validate,
|
||||||
node_ttl => $node_ttl,
|
database_embedded_path => $database_embedded_path,
|
||||||
node_purge_ttl => $node_purge_ttl,
|
node_ttl => $node_ttl,
|
||||||
report_ttl => $report_ttl,
|
node_purge_ttl => $node_purge_ttl,
|
||||||
gc_interval => $gc_interval,
|
report_ttl => $report_ttl,
|
||||||
log_slow_statements => $log_slow_statements,
|
gc_interval => $gc_interval,
|
||||||
conn_max_age => $conn_max_age,
|
log_slow_statements => $log_slow_statements,
|
||||||
conn_keep_alive => $conn_keep_alive,
|
conn_max_age => $conn_max_age,
|
||||||
conn_lifetime => $conn_lifetime,
|
conn_keep_alive => $conn_keep_alive,
|
||||||
confdir => $confdir,
|
conn_lifetime => $conn_lifetime,
|
||||||
notify => Service[$puppetdb_service],
|
confdir => $confdir,
|
||||||
|
notify => Service[$puppetdb_service],
|
||||||
}
|
}
|
||||||
|
|
||||||
class { 'puppetdb::server::read_database_ini':
|
class { 'puppetdb::server::read_database_ini':
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
# PRIVATE CLASS - do not use directly
|
# PRIVATE CLASS - do not use directly
|
||||||
class puppetdb::server::database_ini (
|
class puppetdb::server::database_ini (
|
||||||
$database = $puppetdb::params::database,
|
$database = $puppetdb::params::database,
|
||||||
$database_host = $puppetdb::params::database_host,
|
$database_host = $puppetdb::params::database_host,
|
||||||
$database_port = $puppetdb::params::database_port,
|
$database_port = $puppetdb::params::database_port,
|
||||||
$database_username = $puppetdb::params::database_username,
|
$database_username = $puppetdb::params::database_username,
|
||||||
$database_password = $puppetdb::params::database_password,
|
$database_password = $puppetdb::params::database_password,
|
||||||
$database_name = $puppetdb::params::database_name,
|
$database_name = $puppetdb::params::database_name,
|
||||||
$database_ssl = $puppetdb::params::database_ssl,
|
$database_ssl = $puppetdb::params::database_ssl,
|
||||||
$database_validate = $puppetdb::params::database_validate,
|
$database_validate = $puppetdb::params::database_validate,
|
||||||
$node_ttl = $puppetdb::params::node_ttl,
|
$database_embedded_path = $puppetdb::params::database_embedded_path,
|
||||||
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
$node_ttl = $puppetdb::params::node_ttl,
|
||||||
$report_ttl = $puppetdb::params::report_ttl,
|
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
||||||
$gc_interval = $puppetdb::params::gc_interval,
|
$report_ttl = $puppetdb::params::report_ttl,
|
||||||
$log_slow_statements = $puppetdb::params::log_slow_statements,
|
$gc_interval = $puppetdb::params::gc_interval,
|
||||||
$conn_max_age = $puppetdb::params::conn_max_age,
|
$log_slow_statements = $puppetdb::params::log_slow_statements,
|
||||||
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
|
$conn_max_age = $puppetdb::params::conn_max_age,
|
||||||
$conn_lifetime = $puppetdb::params::conn_lifetime,
|
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
|
||||||
$confdir = $puppetdb::params::confdir,
|
$conn_lifetime = $puppetdb::params::conn_lifetime,
|
||||||
|
$confdir = $puppetdb::params::confdir,
|
||||||
) inherits puppetdb::params {
|
) inherits puppetdb::params {
|
||||||
|
|
||||||
if str2bool($database_validate) {
|
if str2bool($database_validate) {
|
||||||
|
@ -54,7 +55,7 @@ class puppetdb::server::database_ini (
|
||||||
|
|
||||||
$classname = 'org.hsqldb.jdbcDriver'
|
$classname = 'org.hsqldb.jdbcDriver'
|
||||||
$subprotocol = 'hsqldb'
|
$subprotocol = 'hsqldb'
|
||||||
$subname = $puppetdb::params::embedded_subname
|
$subname = "file:${database_embedded_path};hsqldb.tx=mvcc;sql.syntax_pgs=true"
|
||||||
|
|
||||||
} elsif $database == 'postgres' {
|
} elsif $database == 'postgres' {
|
||||||
$classname = 'org.postgresql.Driver'
|
$classname = 'org.postgresql.Driver'
|
||||||
|
|
140
spec/unit/classes/server/database_ini_spec.rb
Normal file
140
spec/unit/classes/server/database_ini_spec.rb
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'puppetdb::server::database_ini', :type => :class do
|
||||||
|
context 'on a supported platform' do
|
||||||
|
let(:facts) do
|
||||||
|
{
|
||||||
|
:osfamily => 'RedHat',
|
||||||
|
:operatingsystem => 'RedHat',
|
||||||
|
:operatingsystemrelease => '7.0',
|
||||||
|
:fqdn => 'test.domain.local',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_class('puppetdb::server::database_ini') }
|
||||||
|
|
||||||
|
describe 'when using default values' do
|
||||||
|
it { should contain_ini_setting('puppetdb_psdatabase_username').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'username',
|
||||||
|
'value' => 'puppetdb'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_psdatabase_password').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'password',
|
||||||
|
'value' => 'puppetdb'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_classname').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'classname',
|
||||||
|
'value' => 'org.postgresql.Driver'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_subprotocol').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'subprotocol',
|
||||||
|
'value' => 'postgresql'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_subname').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'subname',
|
||||||
|
'value' => '//localhost:5432/puppetdb'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_gc_interval').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'gc-interval',
|
||||||
|
'value' => '60'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_node_ttl').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'node-ttl',
|
||||||
|
'value' => '0s'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_node_purge_ttl').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'node-purge-ttl',
|
||||||
|
'value' => '0s'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_report_ttl').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'report-ttl',
|
||||||
|
'value' => '14d'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_log_slow_statements').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'log-slow-statements',
|
||||||
|
'value' => 10
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_conn_max_age').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'conn-max-age',
|
||||||
|
'value' => '60'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_conn_keep_alive').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'conn-keep-alive',
|
||||||
|
'value' => '45'
|
||||||
|
)}
|
||||||
|
it { should contain_ini_setting('puppetdb_conn_lifetime').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'conn-lifetime',
|
||||||
|
'value' => '0'
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when overriding database_path for embedded' do
|
||||||
|
let(:params) do
|
||||||
|
{
|
||||||
|
'database' => 'embedded',
|
||||||
|
'database_embedded_path' => '/tmp/foo',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { should contain_ini_setting('puppetdb_subname').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppetdb/conf.d/database.ini',
|
||||||
|
'section' => 'database',
|
||||||
|
'setting' => 'subname',
|
||||||
|
'value' => 'file:/tmp/foo;hsqldb.tx=mvcc;sql.syntax_pgs=true'
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue