Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions manifests/master/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,8 +64,10 @@
$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,
Expand Down Expand Up @@ -103,9 +112,20 @@
# 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) {
Expand Down
35 changes: 35 additions & 0 deletions manifests/master/report_processor.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Class: puppetdb::master::report_processor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep copying this non-standard puppet doc header ... this is the style we should follow: http://docs.puppetlabs.com/guides/style_guide.html#puppet-doc but we probably need to do this everywhere as well. Its just that running this kind of header through rdoc makes it look terrible. Not a big deal of course, just thought I'd mention it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbarber is it the missing equals signs that you're referring to?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I mean the entire comment for the class.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but I'm only seeing minor differences between what you linked to and what's in this code. Namely: equals signs for headers, asterisks around parameter names... that's pretty much it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cprice-puppet yeah thats about right, names of header sections as well are different (for example 'actions' could just be in the main description, and its 'examples' instead of sample usage). The parameters section renders differently using the format in the style guide also. While it looks like small differences, the difference in rendering makes it more presentable when put through the 'puppet doc' tool. Its not a big deal like I said, I'm happy to do a cleanup of all of this later if you like - getting all the classes, since I'm the one being pedantic :-).

#
# 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 }
}
}
23 changes: 23 additions & 0 deletions spec/system/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't close the 'let' here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha! thx. kind of surprised that didn't throw an error.


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