Add support for enabling puppetdb report processor

This commit is contained in:
Chris Price 2013-05-23 14:21:05 -07:00
parent 652429c8f1
commit 148bddbf30
3 changed files with 80 additions and 2 deletions

View file

@ -21,8 +21,15 @@
# and puppetdb_port parameters in the puppetdb configuration file.
# If false, an existing puppetdb configuration file will be used
# to retrieve server and port values.
# ['manage_report_processor'] - If true, the module will manage the 'reports' field
# in the puppet.conf file to enable or disable the puppetdb
# report processor. Defaults to 'false'.
# ['strict_validation'] - If true, the module will fail if puppetdb is not reachable,
# otherwise it will preconfigure puppetdb without checking.
# ['enable_reports'] - Ignored unless 'manage_report_processor' is `true`, in which
# case this setting will determine whether or not the puppetdb
# report processor is enabled (`true`) or disabled (`false`) in
# the puppet.conf file.
# ['puppet_confdir'] - Puppet's config directory; defaults to /etc/puppet
# ['puppet_conf'] - Puppet's config file; defaults to /etc/puppet/puppet.conf
# ['puppetdb_version'] - The version of the `puppetdb` package that should
@ -57,8 +64,10 @@ class puppetdb::master::config(
$puppetdb_port = 8081,
$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,
$puppetdb_version = $puppetdb::params::puppetdb_version,
@ -103,9 +112,20 @@ class puppetdb::master::config(
# it polls it automatically.
if ($manage_storeconfigs) {
class { 'puppetdb::master::storeconfigs':
puppet_conf => $puppet_conf,
puppet_conf => $puppet_conf,
require => $strict_validation ? { true => Puppetdb_conn_validator['puppetdb_conn'], default => Package[$terminus_package] },
}
}
}
# 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) {
class { 'puppetdb::master::report_processor':
puppet_conf => $puppet_conf,
enable => $enable_reports,
require => $strict_validation ? { true => Puppetdb_conn_validator['puppetdb_conn'], default => Package[$terminus_package] },
}
}
if ($manage_config) {

View file

@ -0,0 +1,35 @@
# Class: puppetdb::master::report_processor
#
# This class configures the puppet master to enable the puppetdb report
# processor
# Parameters:
# ['puppet_conf'] - The puppet config file (defaults to /etc/puppet/puppet.conf)
#
# Actions:
# - Configures the puppet master to use the puppetdb report processor
#
# Requires:
# - Inifile
#
# Sample Usage:
# class { 'puppetdb::master::report_processor':
# puppet_conf => '/etc/puppet/puppet.conf',
# enable => true
# }
#
#
class puppetdb::master::report_processor(
$puppet_conf = $puppetdb::params::puppet_conf,
$enable = false
) inherits puppetdb::params {
ini_subsetting { "puppet.conf/reports/puppetdb":
path => $puppet_conf,
section => 'master',
setting => 'reports',
subsetting => 'puppetdb',
subsetting_separator => ',',
ensure => $enable ? { true => present, default => absent }
}
}

View file

@ -43,4 +43,27 @@ class { 'puppetdb::master::config': }
end
end
end
describe 'enabling report processor' do
let(:pp) do
pp = <<-EOS
class { 'puppetdb::master::config':
manage_report_processor => true,
enable_reports => true
}
EOS
it 'should add the puppetdb report processor to puppet.conf' do
puppet_apply(pp) do |r|
r[:exit_code].should_not eq(1)
end
system_run("cat /etc/puppet/puppet.conf") do |r|
r[:stdout].should =~ /^reports\s*=\s*([^,]+,)*puppetdb(,[^,]+)*$/
end
end
end
end
end