2013-10-21 17:21:12 +02:00
|
|
|
# PRIVATE CLASS - do not use directly
|
2014-10-07 16:06:54 +02:00
|
|
|
class puppetdb::server::database_ini (
|
2012-09-20 23:46:26 +02:00
|
|
|
$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,
|
2013-08-21 10:36:15 +02:00
|
|
|
$database_ssl = $puppetdb::params::database_ssl,
|
2014-12-16 10:08:35 +01:00
|
|
|
$database_validate = $puppetdb::params::database_validate,
|
2013-04-08 19:51:20 +02:00
|
|
|
$node_ttl = $puppetdb::params::node_ttl,
|
|
|
|
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
|
|
|
$report_ttl = $puppetdb::params::report_ttl,
|
2013-04-09 14:40:12 +02:00
|
|
|
$gc_interval = $puppetdb::params::gc_interval,
|
2013-08-07 16:32:19 +02:00
|
|
|
$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,
|
2012-09-20 23:46:26 +02:00
|
|
|
$confdir = $puppetdb::params::confdir,
|
2012-09-18 00:26:32 +02:00
|
|
|
) inherits puppetdb::params {
|
|
|
|
|
2014-12-16 10:08:35 +01:00
|
|
|
if str2bool($database_validate) {
|
|
|
|
# Validate the database connection. If we can't connect, we want to fail
|
|
|
|
# and skip the rest of the configuration, so that we don't leave puppetdb
|
|
|
|
# in a broken state.
|
|
|
|
#
|
|
|
|
# NOTE:
|
|
|
|
# Because of a limitation in the postgres module this will break with
|
|
|
|
# a duplicate declaration if read and write database host+name are the
|
|
|
|
# same.
|
|
|
|
class { 'puppetdb::server::validate_db':
|
|
|
|
database => $database,
|
|
|
|
database_host => $database_host,
|
|
|
|
database_port => $database_port,
|
|
|
|
database_username => $database_username,
|
|
|
|
database_password => $database_password,
|
|
|
|
database_name => $database_name,
|
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
|
|
|
|
2014-12-16 10:08:35 +01:00
|
|
|
$ini_setting_require = str2bool($database_validate) ? {
|
|
|
|
false => undef,
|
|
|
|
default => Class['puppetdb::server::validate_db'],
|
|
|
|
}
|
2014-10-07 16:06:54 +02:00
|
|
|
# Set the defaults
|
2012-09-18 00:26:32 +02:00
|
|
|
Ini_setting {
|
2012-09-20 23:46:26 +02:00
|
|
|
path => "${confdir}/database.ini",
|
|
|
|
ensure => present,
|
|
|
|
section => 'database',
|
2014-12-16 10:08:35 +01:00
|
|
|
require => $ini_setting_require
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
if $database == 'embedded' {
|
2012-09-20 23:46:26 +02:00
|
|
|
|
|
|
|
$classname = 'org.hsqldb.jdbcDriver'
|
|
|
|
$subprotocol = 'hsqldb'
|
2012-10-17 22:28:01 +02:00
|
|
|
$subname = $puppetdb::params::embedded_subname
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2012-09-18 00:26:32 +02:00
|
|
|
} elsif $database == 'postgres' {
|
2012-09-21 01:22:46 +02:00
|
|
|
$classname = 'org.postgresql.Driver'
|
|
|
|
$subprotocol = 'postgresql'
|
2013-08-21 10:36:15 +02:00
|
|
|
|
|
|
|
$subname = $database_ssl ? {
|
|
|
|
true => "//${database_host}:${database_port}/${database_name}?ssl=true",
|
|
|
|
default => "//${database_host}:${database_port}/${database_name}",
|
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
|
2012-09-20 23:46:26 +02:00
|
|
|
##Only setup for postgres
|
|
|
|
ini_setting {'puppetdb_psdatabase_username':
|
|
|
|
setting => 'username',
|
|
|
|
value => $database_username,
|
|
|
|
}
|
|
|
|
|
2013-08-12 22:20:18 +02:00
|
|
|
if $database_password != undef {
|
|
|
|
ini_setting {'puppetdb_psdatabase_password':
|
|
|
|
setting => 'password',
|
|
|
|
value => $database_password,
|
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_classname':
|
2012-09-20 23:46:26 +02:00
|
|
|
setting => 'classname',
|
|
|
|
value => $classname,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_subprotocol':
|
2012-09-20 23:46:26 +02:00
|
|
|
setting => 'subprotocol',
|
|
|
|
value => $subprotocol,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_pgs':
|
2012-09-20 23:46:26 +02:00
|
|
|
setting => 'syntax_pgs',
|
|
|
|
value => true,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_subname':
|
2012-09-20 23:46:26 +02:00
|
|
|
setting => 'subname',
|
|
|
|
value => $subname,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-20 23:46:26 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_gc_interval':
|
2012-09-20 23:46:26 +02:00
|
|
|
setting => 'gc-interval',
|
2013-04-09 14:40:12 +02:00
|
|
|
value => $gc_interval,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2013-02-05 23:34:48 +01:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_node_ttl':
|
2013-02-05 23:34:48 +01:00
|
|
|
setting => 'node-ttl',
|
2013-04-08 19:51:20 +02:00
|
|
|
value => $node_ttl,
|
2013-02-05 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_node_purge_ttl':
|
2013-02-05 23:34:48 +01:00
|
|
|
setting => 'node-purge-ttl',
|
2013-04-08 19:51:20 +02:00
|
|
|
value => $node_purge_ttl,
|
2013-02-05 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_report_ttl':
|
2013-02-05 23:34:48 +01:00
|
|
|
setting => 'report-ttl',
|
2013-04-08 19:51:20 +02:00
|
|
|
value => $report_ttl,
|
2013-02-05 23:34:48 +01:00
|
|
|
}
|
2013-08-07 16:32:19 +02:00
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_log_slow_statements':
|
2013-08-07 16:32:19 +02:00
|
|
|
setting => 'log-slow-statements',
|
|
|
|
value => $log_slow_statements,
|
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_conn_max_age':
|
2013-08-07 16:32:19 +02:00
|
|
|
setting => 'conn-max-age',
|
|
|
|
value => $conn_max_age,
|
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_conn_keep_alive':
|
2013-08-07 16:32:19 +02:00
|
|
|
setting => 'conn-keep-alive',
|
|
|
|
value => $conn_keep_alive,
|
|
|
|
}
|
|
|
|
|
2014-10-07 16:06:54 +02:00
|
|
|
ini_setting { 'puppetdb_conn_lifetime':
|
2013-08-07 16:32:19 +02:00
|
|
|
setting => 'conn-lifetime',
|
|
|
|
value => $conn_lifetime,
|
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|