2013-10-21 17:21:12 +02:00
|
|
|
# Manage puppet configuration. See README.md for more details.
|
2014-10-07 16:06:54 +02:00
|
|
|
class puppetdb::master::config (
|
2013-10-18 18:00:14 +02:00
|
|
|
$puppetdb_server = $::fqdn,
|
2014-10-06 14:25:43 +02:00
|
|
|
$puppetdb_port = defined(Class['puppetdb']) ? {
|
|
|
|
true => $::puppetdb::disable_ssl ? {
|
2014-10-07 16:06:54 +02:00
|
|
|
true => 8080,
|
|
|
|
default => 8081,
|
|
|
|
},
|
2014-04-08 15:08:23 +02:00
|
|
|
default => 8081,
|
|
|
|
},
|
2014-10-06 14:25:43 +02:00
|
|
|
$puppetdb_disable_ssl = defined(Class['puppetdb']) ? {
|
|
|
|
true => $::puppetdb::disable_ssl,
|
|
|
|
default => false,
|
|
|
|
},
|
2015-01-15 10:13:51 +01:00
|
|
|
$masterless = $puppetdb::params::masterless,
|
2013-10-18 18:00:14 +02:00
|
|
|
$puppetdb_soft_write_failure = false,
|
|
|
|
$manage_routes = true,
|
|
|
|
$manage_storeconfigs = true,
|
|
|
|
$manage_report_processor = false,
|
|
|
|
$manage_config = true,
|
|
|
|
$strict_validation = true,
|
|
|
|
$enable_reports = false,
|
|
|
|
$puppet_confdir = $puppetdb::params::puppet_confdir,
|
|
|
|
$puppet_conf = $puppetdb::params::puppet_conf,
|
2015-06-18 22:45:51 +02:00
|
|
|
$terminus_package = $puppetdb::params::terminus_package,
|
2013-10-18 18:00:14 +02:00
|
|
|
$puppet_service_name = $puppetdb::params::puppet_service_name,
|
|
|
|
$puppetdb_startup_timeout = $puppetdb::params::puppetdb_startup_timeout,
|
2015-06-18 22:45:51 +02:00
|
|
|
$test_url = $puppetdb::params::test_url,
|
2014-10-07 16:06:54 +02:00
|
|
|
$restart_puppet = true,
|
2012-09-19 00:52:10 +02:00
|
|
|
) inherits puppetdb::params {
|
|
|
|
|
2015-05-15 23:10:08 +02:00
|
|
|
|
2015-06-18 22:45:51 +02:00
|
|
|
package { $terminus_package:
|
|
|
|
ensure => $puppetdb::params::puppetdb_version,
|
2015-06-17 21:02:09 +02:00
|
|
|
}
|
|
|
|
|
2013-02-23 01:20:04 +01:00
|
|
|
if ($strict_validation) {
|
2014-10-06 14:25:43 +02:00
|
|
|
|
2013-06-04 14:19:53 +02:00
|
|
|
# Validate the puppetdb connection. If we can't connect to puppetdb then we
|
|
|
|
# *must* not perform the other configuration steps, or else
|
2016-02-08 03:47:20 +01:00
|
|
|
|
|
|
|
$conn_puppetdb_server = $manage_config ? {
|
|
|
|
true => $puppetdb_server,
|
|
|
|
default => undef,
|
|
|
|
}
|
|
|
|
$conn_puppetdb_port = $manage_config ? {
|
|
|
|
true => $puppetdb_port,
|
|
|
|
default => undef,
|
|
|
|
}
|
|
|
|
$conn_puppetdb_ssl = $puppetdb_disable_ssl ? {
|
|
|
|
true => false,
|
|
|
|
default => true,
|
|
|
|
}
|
|
|
|
|
2013-06-04 14:19:53 +02:00
|
|
|
puppetdb_conn_validator { 'puppetdb_conn':
|
2016-02-08 03:47:20 +01:00
|
|
|
puppetdb_server => $conn_puppetdb_server,
|
|
|
|
puppetdb_port => $conn_puppetdb_port,
|
|
|
|
use_ssl => $conn_puppetdb_ssl,
|
2013-06-04 14:19:53 +02:00
|
|
|
timeout => $puppetdb_startup_timeout,
|
2015-06-18 22:45:51 +02:00
|
|
|
require => Package[$terminus_package],
|
|
|
|
test_url => $test_url,
|
2013-06-04 14:19:53 +02:00
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
|
2013-06-04 14:19:53 +02:00
|
|
|
# This is a bit of puppet chicanery that allows us to create a
|
|
|
|
# conditional dependency. Basically, we're saying that "if the PuppetDB
|
|
|
|
# service is being managed in this same catalog, it needs to come before
|
|
|
|
# this validator."
|
|
|
|
Service<|title == $puppetdb::params::puppetdb_service|> -> Puppetdb_conn_validator['puppetdb_conn']
|
2013-02-23 01:20:04 +01:00
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
|
2012-09-19 02:21:42 +02:00
|
|
|
# Conditionally manage the `routes.yaml` file. Restart the puppet service
|
|
|
|
# if changes are made.
|
2012-09-18 00:26:32 +02:00
|
|
|
if ($manage_routes) {
|
2016-02-08 03:47:20 +01:00
|
|
|
$routes_require = $strict_validation ? {
|
|
|
|
true => Puppetdb_conn_validator['puppetdb_conn'],
|
|
|
|
default => Package[$terminus_package],
|
|
|
|
}
|
|
|
|
|
2012-09-18 00:26:32 +02:00
|
|
|
class { 'puppetdb::master::routes':
|
|
|
|
puppet_confdir => $puppet_confdir,
|
2015-01-15 10:13:51 +01:00
|
|
|
masterless => $masterless,
|
2016-02-08 03:47:20 +01:00
|
|
|
require => $routes_require,
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-19 02:21:42 +02:00
|
|
|
# Conditionally manage the storeconfigs settings in `puppet.conf`. We don't
|
|
|
|
# need to trigger a restart of the puppet master service for this one, because
|
|
|
|
# it polls it automatically.
|
2012-09-18 00:26:32 +02:00
|
|
|
if ($manage_storeconfigs) {
|
2016-02-08 03:47:20 +01:00
|
|
|
$storeconfigs_require = $strict_validation ? {
|
|
|
|
true => Puppetdb_conn_validator['puppetdb_conn'],
|
|
|
|
default => Package[$terminus_package],
|
|
|
|
}
|
|
|
|
|
2012-09-18 00:26:32 +02:00
|
|
|
class { 'puppetdb::master::storeconfigs':
|
2013-05-23 23:21:05 +02:00
|
|
|
puppet_conf => $puppet_conf,
|
2015-01-15 10:13:51 +01:00
|
|
|
masterless => $masterless,
|
2016-02-08 03:47:20 +01:00
|
|
|
require => $storeconfigs_require,
|
2013-05-23 23:21:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Conditionally manage the puppetdb report processor setting in `puppet.conf`.
|
|
|
|
# We don't need to trigger a restart of the puppet master service for this one,
|
|
|
|
# because it polls it automatically.
|
|
|
|
if ($manage_report_processor) {
|
2016-02-08 03:47:20 +01:00
|
|
|
$report_processor_require = $strict_validation ? {
|
|
|
|
true => Puppetdb_conn_validator['puppetdb_conn'],
|
|
|
|
default => Package[$terminus_package],
|
|
|
|
}
|
|
|
|
|
2013-05-23 23:21:05 +02:00
|
|
|
class { 'puppetdb::master::report_processor':
|
2013-06-04 14:19:53 +02:00
|
|
|
puppet_conf => $puppet_conf,
|
2015-01-15 10:13:51 +01:00
|
|
|
masterless => $masterless,
|
2013-06-04 14:19:53 +02:00
|
|
|
enable => $enable_reports,
|
2016-02-08 03:47:20 +01:00
|
|
|
require => $report_processor_require,
|
2013-05-23 23:21:05 +02:00
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
|
|
|
|
2013-02-23 01:20:04 +01:00
|
|
|
if ($manage_config) {
|
2013-06-04 14:19:53 +02:00
|
|
|
# Manage the `puppetdb.conf` file. Restart the puppet service if changes
|
|
|
|
# are made.
|
2016-02-08 03:47:20 +01:00
|
|
|
$puppetdb_conf_require = $strict_validation ? {
|
|
|
|
true => Puppetdb_conn_validator['puppetdb_conn'],
|
|
|
|
default => Package[$terminus_package],
|
|
|
|
}
|
|
|
|
|
2013-06-04 14:19:53 +02:00
|
|
|
class { 'puppetdb::master::puppetdb_conf':
|
2013-10-18 18:00:14 +02:00
|
|
|
server => $puppetdb_server,
|
|
|
|
port => $puppetdb_port,
|
|
|
|
soft_write_failure => $puppetdb_soft_write_failure,
|
|
|
|
puppet_confdir => $puppet_confdir,
|
2015-06-18 22:45:51 +02:00
|
|
|
legacy_terminus => $puppetdb::params::terminus_package == 'puppetdb-terminus',
|
2016-02-08 03:47:20 +01:00
|
|
|
require => $puppetdb_conf_require,
|
2013-06-04 14:19:53 +02:00
|
|
|
}
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|
2012-09-23 19:05:00 +02:00
|
|
|
|
|
|
|
if ($restart_puppet) {
|
|
|
|
# We will need to restart the puppet master service if certain config
|
|
|
|
# files are changed, so here we make sure it's in the catalog.
|
2012-09-28 20:03:19 +02:00
|
|
|
if ! defined(Service[$puppet_service_name]) {
|
|
|
|
service { $puppet_service_name:
|
2012-09-23 19:05:00 +02:00
|
|
|
ensure => running,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-23 01:20:04 +01:00
|
|
|
if ($manage_config) {
|
|
|
|
Class['puppetdb::master::puppetdb_conf'] ~> Service[$puppet_service_name]
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($manage_routes) {
|
|
|
|
Class['puppetdb::master::routes'] ~> Service[$puppet_service_name]
|
|
|
|
}
|
2012-09-23 19:05:00 +02:00
|
|
|
}
|
|
|
|
|
2012-09-18 00:26:32 +02:00
|
|
|
}
|