Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$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,
Expand Down Expand Up @@ -91,6 +92,7 @@
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,
Expand Down
40 changes: 20 additions & 20 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -69,52 +69,52 @@

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}")
Expand Down
38 changes: 20 additions & 18 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$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,
Expand Down Expand Up @@ -128,24 +129,25 @@
}

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':
Expand Down
37 changes: 19 additions & 18 deletions manifests/server/database_ini.pp
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -54,7 +55,7 @@

$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'
Expand Down
140 changes: 140 additions & 0 deletions spec/unit/classes/server/database_ini_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
require 'spec_helper'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no coverage here, so I've added default coverage+tests for this particular change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


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