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,
|
||||||
|
|
|
@ -70,7 +70,7 @@ 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
|
||||||
|
@ -82,7 +82,7 @@ class puppetdb::params {
|
||||||
}
|
}
|
||||||
'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
|
||||||
|
@ -94,7 +94,7 @@ class puppetdb::params {
|
||||||
}
|
}
|
||||||
'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
|
||||||
|
@ -106,7 +106,7 @@ class puppetdb::params {
|
||||||
}
|
}
|
||||||
'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
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -136,6 +137,7 @@ class puppetdb::server (
|
||||||
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,
|
||||||
|
|
|
@ -8,6 +8,7 @@ class puppetdb::server::database_ini (
|
||||||
$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,
|
||||||
|
@ -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