Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't use pupetlabs-hocon for metrics.conf #622

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 8 additions & 9 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
fixtures:
repositories:
apache: 'https://github.com/puppetlabs/puppetlabs-apache.git'
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
extlib: 'https://github.com/voxpupuli/puppet-extlib.git'
foreman: 'https://github.com/theforeman/puppet-foreman.git'
git: 'https://github.com/theforeman/puppet-git.git'
hocon: 'https://github.com/puppetlabs/puppetlabs-hocon.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
puppetdb: 'https://github.com/puppetlabs/puppetlabs-puppetdb.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
apache: 'https://github.com/puppetlabs/puppetlabs-apache.git'
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
extlib: 'https://github.com/voxpupuli/puppet-extlib.git'
foreman: 'https://github.com/theforeman/puppet-foreman.git'
git: 'https://github.com/theforeman/puppet-git.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
puppetdb: 'https://github.com/puppetlabs/puppetlabs-puppetdb.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'

symlinks:
puppet: "#{source_dir}"
34 changes: 1 addition & 33 deletions manifests/server/puppetserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -300,39 +300,7 @@

file { $metrics_conf:
ensure => $metrics_conf_ensure,
}

$metrics_general_settings = {
'metrics.server-id' => $metrics_server_id,
'metrics.registries.puppetserver.reporters.jmx.enabled' => $metrics_jmx_enable,
'metrics.registries.puppetserver.reporters.graphite.enabled' => $metrics_graphite_enable,
'metrics.reporters.graphite.host' => $metrics_graphite_host,
'metrics.reporters.graphite.port' => $metrics_graphite_port,
'metrics.reporters.graphite.update-interval-seconds' => $metrics_graphite_interval,
}

$metrics_general_settings.each |$setting, $value| {
hocon_setting { $setting:
ensure => present,
path => $metrics_conf,
setting => $setting,
value => $value,
require => File[$metrics_conf],
}
}

$metrics_allowed_settings = $metrics_allowed ? {
undef => absent,
default => present,
}

hocon_setting { 'metrics.registries.puppetserver.metrics-allowed':
ensure => $metrics_allowed_settings,
path => $metrics_conf,
setting => 'metrics.registries.puppetserver.metrics-allowed',
value => $metrics_allowed,
type => 'array',
require => File[$metrics_conf],
content => template('puppet/server/puppetserver/conf.d/metrics.conf.erb'),
}
}
}
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
"name": "puppetlabs/concat",
"version_requirement": ">= 1.0.0 < 5.0.0"
},
{
"name": "puppetlabs/hocon",
"version_requirement": ">= 1.0.0 < 2.0.0"
},
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.0 < 5.0.0"
Expand Down
29 changes: 8 additions & 21 deletions spec/classes/puppet_server_puppetserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,28 +568,15 @@
with_content(%r{^ # Whether to enable http-client metrics; defaults to 'true'.\n metrics-enabled: true$(.*)}).
with_content(%r{^profiler: \{\n # enable or disable profiling for the Ruby code;\n enabled: true})
}
it { should contain_file('/etc/custom/puppetserver/conf.d/metrics.conf').with_ensure('file') }
it {
should contain_hocon_setting('metrics.server-id').
with_path('/etc/custom/puppetserver/conf.d/metrics.conf').
with_setting('metrics.server-id').
with_value('puppetserver.example.com').
with_ensure('present')
}
it {
should contain_hocon_setting('metrics.reporters.graphite.host').
with_path('/etc/custom/puppetserver/conf.d/metrics.conf').
with_setting('metrics.reporters.graphite.host').
with_value('graphitehost.example.com').
with_ensure('present')
}
it {
should contain_hocon_setting('metrics.registries.puppetserver.metrics-allowed').
with_path('/etc/custom/puppetserver/conf.d/metrics.conf').
with_setting('metrics.registries.puppetserver.metrics-allowed').
with_value(['single.element.array']).
with_type('array').
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/metrics.conf').
with_content(%r{^( *)metrics-allowed: \[\n( *)"single.element.array",\n( *)\]}).
with_content(%r{^( *)server-id: "puppetserver.example.com"}).
with_content(%r{^( *)jmx: \{\n( *)enabled: true}).
with_content(%r{^( *)graphite: \{\n( *)enabled: true}).
with_content(%r{^( *)host: "graphitehost.example.com"}).
with_content(%r{^( *)port: 2003}).
with_content(%r{^( *)update-interval-seconds: 5})
}
end

Expand Down
58 changes: 58 additions & 0 deletions templates/server/puppetserver/conf.d/metrics.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# settings related to metrics
metrics: {
# a server id that will be used as part of the namespace for metrics produced
# by this server
server-id: "<%= @metrics_server_id %>"
registries: {
puppetserver: {
# specify metrics to allow in addition to those in the default list
<% if @metrics_allowed -%>
metrics-allowed: [
<%- @metrics_allowed.each do |allowed_host| -%>
"<%= allowed_host %>",
<%- end -%>
]
<%- else -%>>
#metrics-allowed: ["compiler.compile.production"]
<% end -%>
reporters: {
# enable or disable JMX metrics reporter
jmx: {
enabled: <%= @metrics_jmx_enable %>
}
# enable or disable Graphite metrics reporter
graphite: {
enabled: <%= @metrics_graphite_enable %>
}
}
}
}

# this section is used to configure settings for reporters that will send
# the metrics to various destinations for external viewing
reporters: {
graphite: {
# graphite host
host: "<%= @metrics_graphite_host %>"
# graphite metrics port
port: <%= @metrics_graphite_port %>
# how often to send metrics to graphite
update-interval-seconds: <%= @metrics_graphite_interval %>
}
}
metrics-webservice: {
jolokia: {
# Enable or disable the Jolokia-based metrics/v2 endpoint.
# Default is true.
# enabled: false

# Configure any of the settings listed at:
# https://jolokia.org/reference/html/agents.html#war-agent-installation
servlet-init-params: {
# Specify a custom security policy:
# https://jolokia.org/reference/html/security.html
# policyLocation: "file:///etc/puppetlabs/puppetserver/jolokia-access.xml"
}
}
}
}