Merge pull request #185 from kbarber/ticket/stable/pdb-1455-allow-custom-embedded-subname

(PDB-1455) Provide mechanism for modifying default HSQLDB path
Esse commit está contido em:
Andrew Roetker 2015-06-10 12:40:08 -07:00
commit 7577699003
6 arquivos alterados com 205 adições e 56 exclusões

Ver arquivo

@ -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)
####`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`
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.

Ver arquivo

@ -30,6 +30,7 @@ class puppetdb (
$database_ssl = $puppetdb::params::database_ssl,
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
$database_validate = $puppetdb::params::database_validate,
$database_embedded_path = $puppetdb::params::database_embedded_path,
$node_ttl = $puppetdb::params::node_ttl,
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
$report_ttl = $puppetdb::params::report_ttl,
@ -91,6 +92,7 @@ class puppetdb (
database_name => $database_name,
database_ssl => $database_ssl,
database_validate => $database_validate,
database_embedded_path => $database_embedded_path,
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,

Ver arquivo

@ -69,52 +69,52 @@ class puppetdb::params {
case $::osfamily {
'RedHat', 'Suse', 'Archlinux': {
$confdir = '/etc/puppetdb/conf.d'
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
$puppetdb_initconf = '/etc/sysconfig/puppetdb'
$confdir = '/etc/puppetdb/conf.d'
$database_embedded_path = '/var/lib/puppetdb/db/db'
$puppetdb_initconf = '/etc/sysconfig/puppetdb'
if $settings::confdir != undef {
$puppet_confdir = $settings::confdir
} else {
$puppet_confdir = '/etc/puppet'
}
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/etc/puppetdb/ssl'
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/etc/puppetdb/ssl'
}
'Debian': {
$confdir = '/etc/puppetdb/conf.d'
$embedded_subname = 'file:/var/lib/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
$puppetdb_initconf = '/etc/default/puppetdb'
$confdir = '/etc/puppetdb/conf.d'
$database_embedded_path = '/var/lib/puppetdb/db/db'
$puppetdb_initconf = '/etc/default/puppetdb'
if $settings::confdir != undef {
$puppet_confdir = $settings::confdir
} else {
$puppet_confdir = '/etc/puppet'
}
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/etc/puppetdb/ssl'
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/etc/puppetdb/ssl'
}
'OpenBSD': {
$confdir = '/etc/puppetdb/conf.d'
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
$puppetdb_initconf = undef
$confdir = '/etc/puppetdb/conf.d'
$database_embedded_path = '/var/db/puppetdb/db/db'
$puppetdb_initconf = undef
if $settings::confdir != undef {
$puppet_confdir = $settings::confdir
} else {
$puppet_confdir = '/etc/puppet'
}
$puppet_service_name = 'puppetmasterd'
$ssl_dir = '/etc/puppetdb/ssl'
$puppet_service_name = 'puppetmasterd'
$ssl_dir = '/etc/puppetdb/ssl'
}
'FreeBSD': {
$confdir = '/usr/local/etc/puppetdb/conf.d'
$embedded_subname = 'file:/var/db/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
$puppetdb_initconf = undef
$confdir = '/usr/local/etc/puppetdb/conf.d'
$database_embedded_path = '/var/db/puppetdb/db/db'
$puppetdb_initconf = undef
if $settings::confdir != undef {
$puppet_confdir = $settings::confdir
} else {
$puppet_confdir = '/usr/local/etc/puppet'
}
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/usr/local/etc/puppetdb/ssl'
$puppet_service_name = 'puppetmaster'
$ssl_dir = '/usr/local/etc/puppetdb/ssl'
}
default: {
fail("${module_name} does not support your osfamily ${::osfamily}")

Ver arquivo

@ -25,6 +25,7 @@ class puppetdb::server (
$database_name = $puppetdb::params::database_name,
$database_ssl = $puppetdb::params::database_ssl,
$database_validate = $puppetdb::params::database_validate,
$database_embedded_path = $puppetdb::params::database_embedded_path,
$node_ttl = $puppetdb::params::node_ttl,
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
$report_ttl = $puppetdb::params::report_ttl,
@ -128,24 +129,25 @@ class puppetdb::server (
}
class { 'puppetdb::server::database_ini':
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
database_ssl => $database_ssl,
database_validate => $database_validate,
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
gc_interval => $gc_interval,
log_slow_statements => $log_slow_statements,
conn_max_age => $conn_max_age,
conn_keep_alive => $conn_keep_alive,
conn_lifetime => $conn_lifetime,
confdir => $confdir,
notify => Service[$puppetdb_service],
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
database_ssl => $database_ssl,
database_validate => $database_validate,
database_embedded_path => $database_embedded_path,
node_ttl => $node_ttl,
node_purge_ttl => $node_purge_ttl,
report_ttl => $report_ttl,
gc_interval => $gc_interval,
log_slow_statements => $log_slow_statements,
conn_max_age => $conn_max_age,
conn_keep_alive => $conn_keep_alive,
conn_lifetime => $conn_lifetime,
confdir => $confdir,
notify => Service[$puppetdb_service],
}
class { 'puppetdb::server::read_database_ini':

Ver arquivo

@ -1,22 +1,23 @@
# PRIVATE CLASS - do not use directly
class puppetdb::server::database_ini (
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$database_ssl = $puppetdb::params::database_ssl,
$database_validate = $puppetdb::params::database_validate,
$node_ttl = $puppetdb::params::node_ttl,
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
$report_ttl = $puppetdb::params::report_ttl,
$gc_interval = $puppetdb::params::gc_interval,
$log_slow_statements = $puppetdb::params::log_slow_statements,
$conn_max_age = $puppetdb::params::conn_max_age,
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
$conn_lifetime = $puppetdb::params::conn_lifetime,
$confdir = $puppetdb::params::confdir,
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$database_ssl = $puppetdb::params::database_ssl,
$database_validate = $puppetdb::params::database_validate,
$database_embedded_path = $puppetdb::params::database_embedded_path,
$node_ttl = $puppetdb::params::node_ttl,
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
$report_ttl = $puppetdb::params::report_ttl,
$gc_interval = $puppetdb::params::gc_interval,
$log_slow_statements = $puppetdb::params::log_slow_statements,
$conn_max_age = $puppetdb::params::conn_max_age,
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
$conn_lifetime = $puppetdb::params::conn_lifetime,
$confdir = $puppetdb::params::confdir,
) inherits puppetdb::params {
if str2bool($database_validate) {
@ -54,7 +55,7 @@ class puppetdb::server::database_ini (
$classname = 'org.hsqldb.jdbcDriver'
$subprotocol = 'hsqldb'
$subname = $puppetdb::params::embedded_subname
$subname = "file:${database_embedded_path};hsqldb.tx=mvcc;sql.syntax_pgs=true"
} elsif $database == 'postgres' {
$classname = 'org.postgresql.Driver'

Ver arquivo

@ -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