Skip to content

Commit 2da3eee

Browse files
committed
(PDB-1455) Provide mechanism for modifying default HSQLDB path
This provides an override mechanism for providing a custom path to HSQLDB. This allows users to provide any path to their HSQLDB database. It is needed specifically for managing the as-yet-unreleased version of PuppetDB as well. Signed-off-by: Ken Barber <ken@bob.sh>
1 parent 9dd94b0 commit 2da3eee

6 files changed

Lines changed: 154 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ Setting up proper trust- and keystores has to be managed outside of the puppetdb
257257

258258
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)
259259

260+
####`database_path`
261+
262+
*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).
263+
260264
####`node_ttl`
261265

262266
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.

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
$database_ssl = $puppetdb::params::database_ssl,
3131
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
3232
$database_validate = $puppetdb::params::database_validate,
33+
$database_path = $puppetdb::params::database_path,
3334
$node_ttl = $puppetdb::params::node_ttl,
3435
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
3536
$report_ttl = $puppetdb::params::report_ttl,
@@ -91,6 +92,7 @@
9192
database_name => $database_name,
9293
database_ssl => $database_ssl,
9394
database_validate => $database_validate,
95+
database_path => $database_path,
9496
node_ttl => $node_ttl,
9597
node_purge_ttl => $node_purge_ttl,
9698
report_ttl => $report_ttl,

manifests/params.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
case $::osfamily {
7171
'RedHat', 'Suse', 'Archlinux': {
7272
$confdir = '/etc/puppetdb/conf.d'
73-
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
73+
$database_path = '/var/lib/puppetdb/db/db'
7474
$puppetdb_initconf = '/etc/sysconfig/puppetdb'
7575
if $settings::confdir != undef {
7676
$puppet_confdir = $settings::confdir
@@ -82,7 +82,7 @@
8282
}
8383
'Debian': {
8484
$confdir = '/etc/puppetdb/conf.d'
85-
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
85+
$database_path = '/var/lib/puppetdb/db/db'
8686
$puppetdb_initconf = '/etc/default/puppetdb'
8787
if $settings::confdir != undef {
8888
$puppet_confdir = $settings::confdir
@@ -94,7 +94,7 @@
9494
}
9595
'OpenBSD': {
9696
$confdir = '/etc/puppetdb/conf.d'
97-
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
97+
$database_path = '/var/db/puppetdb/db/db'
9898
$puppetdb_initconf = undef
9999
if $settings::confdir != undef {
100100
$puppet_confdir = $settings::confdir
@@ -106,7 +106,7 @@
106106
}
107107
'FreeBSD': {
108108
$confdir = '/usr/local/etc/puppetdb/conf.d'
109-
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
109+
$database_path = '/var/db/puppetdb/db/db'
110110
$puppetdb_initconf = undef
111111
if $settings::confdir != undef {
112112
$puppet_confdir = $settings::confdir

manifests/server.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
$database_name = $puppetdb::params::database_name,
2626
$database_ssl = $puppetdb::params::database_ssl,
2727
$database_validate = $puppetdb::params::database_validate,
28+
$database_path = $puppetdb::params::database_path,
2829
$node_ttl = $puppetdb::params::node_ttl,
2930
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
3031
$report_ttl = $puppetdb::params::report_ttl,
@@ -136,6 +137,7 @@
136137
database_name => $database_name,
137138
database_ssl => $database_ssl,
138139
database_validate => $database_validate,
140+
database_path => $database_path,
139141
node_ttl => $node_ttl,
140142
node_purge_ttl => $node_purge_ttl,
141143
report_ttl => $report_ttl,

manifests/server/database_ini.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
$database_name = $puppetdb::params::database_name,
99
$database_ssl = $puppetdb::params::database_ssl,
1010
$database_validate = $puppetdb::params::database_validate,
11+
$database_path = $puppetdb::params::database_path,
1112
$node_ttl = $puppetdb::params::node_ttl,
1213
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
1314
$report_ttl = $puppetdb::params::report_ttl,
@@ -54,7 +55,7 @@
5455

5556
$classname = 'org.hsqldb.jdbcDriver'
5657
$subprotocol = 'hsqldb'
57-
$subname = $puppetdb::params::embedded_subname
58+
$subname = "file:${database_path};hsqldb.tx=mvcc;sql.syntax_pgs=true"
5859

5960
} elsif $database == 'postgres' {
6061
$classname = 'org.postgresql.Driver'
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
require 'spec_helper'
2+
3+
describe 'puppetdb::server::database_ini', :type => :class do
4+
context 'on a supported platform' do
5+
let(:facts) do
6+
{
7+
:osfamily => 'RedHat',
8+
:operatingsystem => 'RedHat',
9+
:operatingsystemrelease => '7.0',
10+
:fqdn => 'test.domain.local',
11+
}
12+
end
13+
14+
it { should contain_class('puppetdb::server::database_ini') }
15+
16+
describe 'when using default values' do
17+
it { should contain_ini_setting('puppetdb_psdatabase_username').
18+
with(
19+
'ensure' => 'present',
20+
'path' => '/etc/puppetdb/conf.d/database.ini',
21+
'section' => 'database',
22+
'setting' => 'username',
23+
'value' => 'puppetdb',
24+
)}
25+
it { should contain_ini_setting('puppetdb_psdatabase_password').
26+
with(
27+
'ensure' => 'present',
28+
'path' => '/etc/puppetdb/conf.d/database.ini',
29+
'section' => 'database',
30+
'setting' => 'password',
31+
'value' => 'puppetdb',
32+
)}
33+
it { should contain_ini_setting('puppetdb_classname').
34+
with(
35+
'ensure' => 'present',
36+
'path' => '/etc/puppetdb/conf.d/database.ini',
37+
'section' => 'database',
38+
'setting' => 'classname',
39+
'value' => 'org.postgresql.Driver'
40+
)}
41+
it { should contain_ini_setting('puppetdb_subprotocol').
42+
with(
43+
'ensure' => 'present',
44+
'path' => '/etc/puppetdb/conf.d/database.ini',
45+
'section' => 'database',
46+
'setting' => 'subprotocol',
47+
'value' => 'postgresql',
48+
)}
49+
it { should contain_ini_setting('puppetdb_subname').
50+
with(
51+
'ensure' => 'present',
52+
'path' => '/etc/puppetdb/conf.d/database.ini',
53+
'section' => 'database',
54+
'setting' => 'subname',
55+
'value' => '//localhost:5432/puppetdb',
56+
)}
57+
it { should contain_ini_setting('puppetdb_gc_interval').
58+
with(
59+
'ensure' => 'present',
60+
'path' => '/etc/puppetdb/conf.d/database.ini',
61+
'section' => 'database',
62+
'setting' => 'gc-interval',
63+
'value' => '60',
64+
)}
65+
it { should contain_ini_setting('puppetdb_node_ttl').
66+
with(
67+
'ensure' => 'present',
68+
'path' => '/etc/puppetdb/conf.d/database.ini',
69+
'section' => 'database',
70+
'setting' => 'node-ttl',
71+
'value' => '0s',
72+
)}
73+
it { should contain_ini_setting('puppetdb_node_purge_ttl').
74+
with(
75+
'ensure' => 'present',
76+
'path' => '/etc/puppetdb/conf.d/database.ini',
77+
'section' => 'database',
78+
'setting' => 'node-purge-ttl',
79+
'value' => '0s',
80+
)}
81+
it { should contain_ini_setting('puppetdb_report_ttl').
82+
with(
83+
'ensure' => 'present',
84+
'path' => '/etc/puppetdb/conf.d/database.ini',
85+
'section' => 'database',
86+
'setting' => 'report-ttl',
87+
'value' => '14d',
88+
)}
89+
it { should contain_ini_setting('puppetdb_log_slow_statements').
90+
with(
91+
'ensure' => 'present',
92+
'path' => '/etc/puppetdb/conf.d/database.ini',
93+
'section' => 'database',
94+
'setting' => 'log-slow-statements',
95+
'value' => 10,
96+
)}
97+
it { should contain_ini_setting('puppetdb_conn_max_age').
98+
with(
99+
'ensure' => 'present',
100+
'path' => '/etc/puppetdb/conf.d/database.ini',
101+
'section' => 'database',
102+
'setting' => 'conn-max-age',
103+
'value' => '60',
104+
)}
105+
it { should contain_ini_setting('puppetdb_conn_keep_alive').
106+
with(
107+
'ensure' => 'present',
108+
'path' => '/etc/puppetdb/conf.d/database.ini',
109+
'section' => 'database',
110+
'setting' => 'conn-keep-alive',
111+
'value' => '45',
112+
)}
113+
it { should contain_ini_setting('puppetdb_conn_lifetime').
114+
with(
115+
'ensure' => 'present',
116+
'path' => '/etc/puppetdb/conf.d/database.ini',
117+
'section' => 'database',
118+
'setting' => 'conn-lifetime',
119+
'value' => '0',
120+
)}
121+
end
122+
123+
describe 'when overriding database_path for embedded' do
124+
let(:params) do
125+
{
126+
'database' => 'embedded',
127+
'database_path' => '/tmp/foo',
128+
}
129+
end
130+
it { should contain_ini_setting('puppetdb_subname').
131+
with(
132+
'ensure' => 'present',
133+
'path' => '/etc/puppetdb/conf.d/database.ini',
134+
'section' => 'database',
135+
'setting' => 'subname',
136+
'value' => 'file:/tmp/foo;hsqldb.tx=mvcc;sql.syntax_pgs=true',
137+
)}
138+
end
139+
end
140+
end

0 commit comments

Comments
 (0)