Allow puppetdb to be configure for masterless conf

Currently the module only allows PuppetDB to be configured in a
agent/master setup configuration, by configuring the master section of
the puppet.conf and applying on the routes for such a configuration.
This commit allows one to use this module to configure the main section of
the puppet.conf and applying the proper routes so the module can configure
nodes to use PuppetDB in a masterless setup.

Doc about puppet.conf configure in masterless way available here
https://docs.puppetlabs.com/puppetdb/2.2/connect_puppet_apply.html#manage-puppetconf
This commit is contained in:
Yanis Guenane 2015-01-15 04:13:51 -05:00 committed by Yanis Guenane
parent d4de12fb6d
commit a826d85735
7 changed files with 48 additions and 6 deletions

View file

@ -492,6 +492,10 @@ Puppet's config directory (defaults to `/etc/puppet`).
Puppet's config file (defaults to `/etc/puppet/puppet.conf`).
####`masterless`
A boolean switch to enable or disable the masterless setup of PuppetDB.
####`puppetdb_version`
The version of the `puppetdb` package that should be installed. You may specify an explicit version number, 'present', or 'latest' (defaults to 'present').

View file

@ -12,6 +12,7 @@ class puppetdb::master::config (
true => $::puppetdb::disable_ssl,
default => false,
},
$masterless = $puppetdb::params::masterless,
$puppetdb_soft_write_failure = false,
$manage_routes = true,
$manage_storeconfigs = true,
@ -67,6 +68,7 @@ class puppetdb::master::config (
if ($manage_routes) {
class { 'puppetdb::master::routes':
puppet_confdir => $puppet_confdir,
masterless => $masterless,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
@ -80,6 +82,7 @@ class puppetdb::master::config (
if ($manage_storeconfigs) {
class { 'puppetdb::master::storeconfigs':
puppet_conf => $puppet_conf,
masterless => $masterless,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],
default => Package[$terminus_package],
@ -93,6 +96,7 @@ class puppetdb::master::config (
if ($manage_report_processor) {
class { 'puppetdb::master::report_processor':
puppet_conf => $puppet_conf,
masterless => $masterless,
enable => $enable_reports,
require => $strict_validation ? {
true => Puppetdb_conn_validator['puppetdb_conn'],

View file

@ -2,15 +2,23 @@
# for more details.
class puppetdb::master::report_processor (
$puppet_conf = $puppetdb::params::puppet_conf,
$masterless = $puppetdb::params::masterless,
$enable = false
) inherits puppetdb::params {
if $masterless {
$puppet_conf_section = 'main'
} else {
$puppet_conf_section = 'master'
}
ini_subsetting { 'puppet.conf/reports/puppetdb':
ensure => $enable ? {
true => present,
default => absent
},
path => $puppet_conf,
section => 'master',
section => $puppet_conf_section,
setting => 'reports',
subsetting => 'puppetdb',
subsetting_separator => ',',

View file

@ -2,7 +2,8 @@
# details.
class puppetdb::master::routes (
$puppet_confdir = $puppetdb::params::puppet_confdir,
$routes = {
$masterless = $puppetdb::params::masterless,
$routes = {
'master' => {
'facts' => {
'terminus' => 'puppetdb',
@ -12,6 +13,23 @@ class puppetdb::master::routes (
}
) inherits puppetdb::params {
if $masterless {
$routes_real = {
'apply' => {
'catalog' => {
'terminus' => 'compiler',
'cache' => 'puppetdb',
},
'facts' => {
'terminus' => 'facter',
'cache' => 'puppetdb_apply',
}
}
}
} else {
$routes_real = $routes
}
# TODO: this will overwrite any existing routes.yaml;
# to handle this properly we should just be ensuring
# that the proper settings exist, but to do that we'd need

View file

@ -2,20 +2,27 @@
# puppetdb as the storeconfigs backend. See README.md for more details.
class puppetdb::master::storeconfigs (
$puppet_conf = $puppetdb::params::puppet_conf,
$masterless = $puppetdb::params::masterless,
) inherits puppetdb::params {
if $masterless {
$puppet_conf_section = 'main'
} else {
$puppet_conf_section = 'master'
}
Ini_setting {
section => 'master',
section => $puppet_conf_section,
path => $puppet_conf,
ensure => present,
}
ini_setting { 'puppet.conf/master/storeconfigs':
ini_setting { "puppet.conf/${puppet_conf_section}/storeconfigs":
setting => 'storeconfigs',
value => true,
}
ini_setting { 'puppet.conf/master/storeconfigs_backend':
ini_setting { "puppet.conf/${puppet_conf_section}/storeconfigs_backend":
setting => 'storeconfigs_backend',
value => 'puppetdb',
}

View file

@ -64,6 +64,7 @@ class puppetdb::params {
$puppetdb_group = 'puppetdb'
$confdir = '/etc/puppetdb/conf.d'
$puppet_confdir = '/etc/puppet'
$masterless = false
$terminus_package = 'puppetdb-terminus'
$ssl_dir = '/etc/puppetdb/ssl'

View file

@ -1,3 +1,3 @@
# This file was automatically generated by the puppetdb module.
<%= @routes.to_yaml %>
<%= @routes_real.to_yaml %>