Merge pull request #64 from cprice-puppet/feature/master/support-enabling-report-processor
Add support for enabling puppetdb report processor
This commit is contained in:
commit
b45fca9689
7 changed files with 150 additions and 4 deletions
16
CHANGELOG
16
CHANGELOG
|
@ -2,6 +2,22 @@
|
||||||
|
|
||||||
Release notes for the puppetlabs-puppetdb module.
|
Release notes for the puppetlabs-puppetdb module.
|
||||||
|
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
#### 1.4.0 - 2013/05/13
|
||||||
|
|
||||||
|
This feature release provides support for managing the puppetdb report
|
||||||
|
processor on your master.
|
||||||
|
|
||||||
|
To enable the report processor, you can do something like this:
|
||||||
|
|
||||||
|
class { 'puppetdb::master::config':
|
||||||
|
manage_report_processor => true,
|
||||||
|
enable_reports => true
|
||||||
|
}
|
||||||
|
|
||||||
|
This will add the 'puppetdb' report processor to the list of `reports`
|
||||||
|
inside your master's `puppet.conf` file.
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name 'puppetlabs-puppetdb'
|
name 'puppetlabs-puppetdb'
|
||||||
version '1.3.0'
|
version '1.4.0'
|
||||||
source 'git://github.com/puppetlabs/puppetlabs-puppetdb.git'
|
source 'git://github.com/puppetlabs/puppetlabs-puppetdb.git'
|
||||||
author 'Puppet Labs'
|
author 'Puppet Labs'
|
||||||
description 'PuppetDB resource types'
|
description 'PuppetDB resource types'
|
||||||
|
@ -7,7 +7,7 @@ summary 'PuppetDB resource types'
|
||||||
license 'ASL 2.0'
|
license 'ASL 2.0'
|
||||||
project_page 'https://github.com/puppetlabs/puppetlabs-puppetdb'
|
project_page 'https://github.com/puppetlabs/puppetlabs-puppetdb'
|
||||||
|
|
||||||
dependency 'cprice404/inifile', '>= 0.9.0'
|
dependency 'cprice404/inifile', '>= 0.10.3'
|
||||||
dependency 'puppetlabs/postgresql', '2.x'
|
dependency 'puppetlabs/postgresql', '2.x'
|
||||||
dependency 'puppetlabs/firewall', '>= 0.0.4'
|
dependency 'puppetlabs/firewall', '>= 0.0.4'
|
||||||
dependency 'puppetlabs/stdlib', '>= 1.0.0'
|
dependency 'puppetlabs/stdlib', '>= 1.0.0'
|
||||||
|
|
|
@ -282,6 +282,10 @@ If true, the module will overwrite the puppet master's routes file to configure
|
||||||
|
|
||||||
If true, the module will manage the puppet master's storeconfig settings (defaults to true).
|
If true, the module will manage the puppet master's storeconfig settings (defaults to true).
|
||||||
|
|
||||||
|
####`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'.
|
||||||
|
|
||||||
####`manage_config`
|
####`manage_config`
|
||||||
If true, the module will store values from puppetdb_server and puppetdb_port parameters in the puppetdb configuration file.
|
If true, the module will store values from puppetdb_server 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.
|
If false, an existing puppetdb configuration file will be used to retrieve server and port values.
|
||||||
|
@ -289,6 +293,10 @@ If false, an existing puppetdb configuration file will be used to retrieve serve
|
||||||
####`strict_validation`
|
####`strict_validation`
|
||||||
If true, the module will fail if puppetdb is not reachable, otherwise it will preconfigure puppetdb without checking.
|
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_confdir`
|
||||||
|
|
||||||
Puppet's config directory (defaults to `/etc/puppet`).
|
Puppet's config directory (defaults to `/etc/puppet`).
|
||||||
|
|
|
@ -21,8 +21,15 @@
|
||||||
# and puppetdb_port parameters in the puppetdb configuration file.
|
# and puppetdb_port parameters in the puppetdb configuration file.
|
||||||
# If false, an existing puppetdb configuration file will be used
|
# If false, an existing puppetdb configuration file will be used
|
||||||
# to retrieve server and port values.
|
# 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,
|
# ['strict_validation'] - If true, the module will fail if puppetdb is not reachable,
|
||||||
# otherwise it will preconfigure puppetdb without checking.
|
# 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_confdir'] - Puppet's config directory; defaults to /etc/puppet
|
||||||
# ['puppet_conf'] - Puppet's config file; defaults to /etc/puppet/puppet.conf
|
# ['puppet_conf'] - Puppet's config file; defaults to /etc/puppet/puppet.conf
|
||||||
# ['puppetdb_version'] - The version of the `puppetdb` package that should
|
# ['puppetdb_version'] - The version of the `puppetdb` package that should
|
||||||
|
@ -57,8 +64,10 @@ class puppetdb::master::config(
|
||||||
$puppetdb_port = 8081,
|
$puppetdb_port = 8081,
|
||||||
$manage_routes = true,
|
$manage_routes = true,
|
||||||
$manage_storeconfigs = true,
|
$manage_storeconfigs = true,
|
||||||
|
$manage_report_processor = false,
|
||||||
$manage_config = true,
|
$manage_config = true,
|
||||||
$strict_validation = true,
|
$strict_validation = true,
|
||||||
|
$enable_reports = false,
|
||||||
$puppet_confdir = $puppetdb::params::puppet_confdir,
|
$puppet_confdir = $puppetdb::params::puppet_confdir,
|
||||||
$puppet_conf = $puppetdb::params::puppet_conf,
|
$puppet_conf = $puppetdb::params::puppet_conf,
|
||||||
$puppetdb_version = $puppetdb::params::puppetdb_version,
|
$puppetdb_version = $puppetdb::params::puppetdb_version,
|
||||||
|
@ -108,6 +117,17 @@ class puppetdb::master::config(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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) {
|
if ($manage_config) {
|
||||||
# Manage the `puppetdb.conf` file. Restart the puppet service if changes
|
# Manage the `puppetdb.conf` file. Restart the puppet service if changes
|
||||||
# are made.
|
# are made.
|
||||||
|
|
35
manifests/master/report_processor.pp
Normal file
35
manifests/master/report_processor.pp
Normal 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 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,4 +43,27 @@ class { 'puppetdb::master::config': }
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
44
spec/unit/classes/master/report_processor_spec.rb
Normal file
44
spec/unit/classes/master/report_processor_spec.rb
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'puppetdb::master::report_processor', :type => :class do
|
||||||
|
context 'on a supported platform' do
|
||||||
|
let(:facts) do
|
||||||
|
{
|
||||||
|
:osfamily => 'RedHat',
|
||||||
|
:clientcert => 'test.domain.local',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should include_class('puppetdb::master::report_processor') }
|
||||||
|
|
||||||
|
describe 'when using default values' do
|
||||||
|
it { should contain_ini_subsetting('puppet.conf/reports/puppetdb').
|
||||||
|
with(
|
||||||
|
'ensure' => 'absent',
|
||||||
|
'path' => '/etc/puppet/puppet.conf',
|
||||||
|
'section' => 'master',
|
||||||
|
'setting' => 'reports',
|
||||||
|
'subsetting' => 'puppetdb',
|
||||||
|
'subsetting_separator' => ','
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when enabling reports' do
|
||||||
|
let(:params) do
|
||||||
|
{
|
||||||
|
'enable' => true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_ini_subsetting('puppet.conf/reports/puppetdb').
|
||||||
|
with(
|
||||||
|
'ensure' => 'present',
|
||||||
|
'path' => '/etc/puppet/puppet.conf',
|
||||||
|
'section' => 'master',
|
||||||
|
'setting' => 'reports',
|
||||||
|
'subsetting' => 'puppetdb',
|
||||||
|
'subsetting_separator' => ','
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue