2013-10-21 17:21:12 +02:00
|
|
|
# Class to configure a PuppetDB server. See README.md for more details.
|
2012-06-15 00:04:42 +02:00
|
|
|
class puppetdb::server(
|
2012-11-13 21:38:38 +01:00
|
|
|
$listen_address = $puppetdb::params::listen_address,
|
|
|
|
$listen_port = $puppetdb::params::listen_port,
|
|
|
|
$open_listen_port = $puppetdb::params::open_listen_port,
|
2012-09-20 23:46:26 +02:00
|
|
|
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
|
|
|
|
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
|
2013-04-09 00:39:04 +02:00
|
|
|
$disable_ssl = $puppetdb::params::disable_ssl,
|
2012-11-13 21:38:38 +01:00
|
|
|
$open_ssl_listen_port = $puppetdb::params::open_ssl_listen_port,
|
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,
|
2013-02-05 23:34:48 +01:00
|
|
|
$node_ttl = $puppetdb::params::node_ttl,
|
|
|
|
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
|
|
|
|
$report_ttl = $puppetdb::params::report_ttl,
|
2013-08-07 16:32:19 +02:00
|
|
|
$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,
|
2013-10-21 17:21:12 +02:00
|
|
|
$conn_lifetime = $puppetdb::params::conn_lifetime,
|
2012-09-28 20:03:19 +02:00
|
|
|
$puppetdb_package = $puppetdb::params::puppetdb_package,
|
2012-09-20 23:46:26 +02:00
|
|
|
$puppetdb_version = $puppetdb::params::puppetdb_version,
|
2012-09-28 20:03:19 +02:00
|
|
|
$puppetdb_service = $puppetdb::params::puppetdb_service,
|
2013-09-02 11:30:31 +02:00
|
|
|
$puppetdb_service_status = $puppetdb::params::puppetdb_service_status,
|
2012-09-20 23:46:26 +02:00
|
|
|
$confdir = $puppetdb::params::confdir,
|
2013-02-15 17:16:36 +01:00
|
|
|
$java_args = {}
|
2012-06-15 00:04:42 +02:00
|
|
|
) inherits puppetdb::params {
|
|
|
|
|
2013-04-08 23:49:18 +02:00
|
|
|
# Apply necessary suffix if zero is specified.
|
|
|
|
if $node_ttl == '0' {
|
|
|
|
$node_ttl_real = '0s'
|
|
|
|
} else {
|
|
|
|
$node_ttl_real = downcase($node_ttl)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Validate node_ttl
|
|
|
|
validate_re ($node_ttl_real, ['^(\d)+[s,m,d]$'], "node_ttl is <${node_ttl}> which does not match the regex validation")
|
|
|
|
|
|
|
|
# Apply necessary suffix if zero is specified.
|
|
|
|
if $node_purge_ttl == '0' {
|
|
|
|
$node_purge_ttl_real = '0s'
|
|
|
|
} else {
|
|
|
|
$node_purge_ttl_real = downcase($node_purge_ttl)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Validate node_purge_ttl
|
|
|
|
validate_re ($node_purge_ttl_real, ['^(\d)+[s,m,d]$'], "node_purge_ttl is <${node_purge_ttl}> which does not match the regex validation")
|
|
|
|
|
|
|
|
# Apply necessary suffix if zero is specified.
|
|
|
|
if $report_ttl == '0' {
|
|
|
|
$report_ttl_real = '0s'
|
|
|
|
} else {
|
|
|
|
$report_ttl_real = downcase($report_ttl)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Validate report_ttl
|
|
|
|
validate_re ($report_ttl_real, ['^(\d)+[s,m,d]$'], "report_ttl is <${report_ttl}> which does not match the regex validation")
|
|
|
|
|
2013-09-02 11:30:31 +02:00
|
|
|
# Validate puppetdb_service_status
|
|
|
|
if !($puppetdb_service_status in ['true', 'running', 'false', 'stopped']) {
|
|
|
|
fail("puppetdb_service_status valid values are 'true', 'running', 'false', and 'stopped'. You provided '${puppetdb_service_status}'")
|
|
|
|
}
|
|
|
|
|
2012-09-28 20:03:19 +02:00
|
|
|
package { $puppetdb_package:
|
2012-09-20 23:46:26 +02:00
|
|
|
ensure => $puppetdb_version,
|
2012-09-28 20:03:19 +02:00
|
|
|
notify => Service[$puppetdb_service],
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-06-15 00:04:42 +02:00
|
|
|
|
2012-09-20 23:46:26 +02:00
|
|
|
class { 'puppetdb::server::firewall':
|
2012-11-13 21:38:38 +01:00
|
|
|
http_port => $listen_port,
|
|
|
|
open_http_port => $open_listen_port,
|
|
|
|
ssl_port => $ssl_listen_port,
|
|
|
|
open_ssl_port => $open_ssl_listen_port,
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-09-18 02:06:48 +02:00
|
|
|
|
2012-09-20 23:46:26 +02:00
|
|
|
class { 'puppetdb::server::database_ini':
|
2013-08-21 10:36:15 +02:00
|
|
|
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,
|
|
|
|
node_ttl => $node_ttl,
|
|
|
|
node_purge_ttl => $node_purge_ttl,
|
|
|
|
report_ttl => $report_ttl,
|
|
|
|
gc_interval => $gc_interval,
|
2013-08-07 16:32:19 +02:00
|
|
|
log_slow_statements => $log_slow_statements,
|
2013-08-21 10:36:15 +02:00
|
|
|
conn_max_age => $conn_max_age,
|
|
|
|
conn_keep_alive => $conn_keep_alive,
|
|
|
|
conn_lifetime => $conn_lifetime,
|
|
|
|
confdir => $confdir,
|
|
|
|
notify => Service[$puppetdb_service],
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-09-06 16:56:26 +02:00
|
|
|
|
2012-09-20 23:46:26 +02:00
|
|
|
class { 'puppetdb::server::jetty_ini':
|
2012-11-13 21:38:38 +01:00
|
|
|
listen_address => $listen_address,
|
|
|
|
listen_port => $listen_port,
|
2012-09-20 23:46:26 +02:00
|
|
|
ssl_listen_address => $ssl_listen_address,
|
|
|
|
ssl_listen_port => $ssl_listen_port,
|
2013-04-09 00:39:04 +02:00
|
|
|
disable_ssl => $disable_ssl,
|
2012-09-20 23:46:26 +02:00
|
|
|
confdir => $confdir,
|
2012-09-28 20:03:19 +02:00
|
|
|
notify => Service[$puppetdb_service],
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-09-06 16:56:26 +02:00
|
|
|
|
2013-02-15 17:16:36 +01:00
|
|
|
if !empty($java_args) {
|
2013-06-04 14:19:53 +02:00
|
|
|
|
2013-02-15 17:16:36 +01:00
|
|
|
create_resources(
|
|
|
|
'ini_subsetting',
|
|
|
|
puppetdb_create_subsetting_resource_hash(
|
|
|
|
$java_args,
|
|
|
|
{ ensure => present,
|
|
|
|
section => '',
|
|
|
|
key_val_separator => '=',
|
|
|
|
path => $puppetdb::params::puppetdb_initconf,
|
|
|
|
setting => 'JAVA_ARGS',
|
|
|
|
require => Package[$puppetdb_package],
|
|
|
|
notify => Service[$puppetdb_service],
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2013-09-02 11:30:31 +02:00
|
|
|
$service_enabled = $puppetdb_service_status ? {
|
|
|
|
/(running|true)/ => true,
|
|
|
|
/(stopped|false)/ => false,
|
|
|
|
default => true,
|
|
|
|
}
|
|
|
|
|
2012-09-28 20:03:19 +02:00
|
|
|
service { $puppetdb_service:
|
2013-09-02 11:30:31 +02:00
|
|
|
ensure => $puppetdb_service_status,
|
|
|
|
enable => $service_enabled,
|
2012-09-20 23:46:26 +02:00
|
|
|
}
|
2012-09-06 16:56:26 +02:00
|
|
|
|
2012-09-28 20:03:19 +02:00
|
|
|
Package[$puppetdb_package] ->
|
2012-09-20 23:46:26 +02:00
|
|
|
Class['puppetdb::server::firewall'] ->
|
|
|
|
Class['puppetdb::server::database_ini'] ->
|
|
|
|
Class['puppetdb::server::jetty_ini'] ->
|
2012-09-28 20:03:19 +02:00
|
|
|
Service[$puppetdb_service]
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|