Skip to content

Commit

Permalink
Fix hiera_merge behavior (#28)
Browse files Browse the repository at this point in the history
Fixes #27. This wasn't implemented correctly in #25. The `$telegraf::params::inputs` and `$telegraf::params::outputs` values are never read because they are only provided as a default value.
  • Loading branch information
joshuaspence authored and yankcrime committed Jun 1, 2016
1 parent bf45b4b commit 627c93e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
validate_bool($manage_service)
validate_bool($manage_repo)

# currently the only way how to obtain merged hashes
# from multiple files (`:merge_behavior: deeper` needs to be
# set in your `hiera.yaml`)
$_outputs = hiera_hash('telegraf::outputs', $outputs)
$_inputs = hiera_hash('telegraf::inputs', $inputs)

contain ::telegraf::install
contain ::telegraf::config
contain ::telegraf::service
Expand Down
11 changes: 4 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,19 @@
$manage_service = true
$manage_repo = true

# currently the only way how to obtain merged hashes
# from multiple files (`:merge_behavior: deeper` needs to be
# set in your `hiera.yaml`)
$outputs = hiera_hash('telegraf::outputs', {
$outputs = {
'influxdb' => {
'urls' => [ 'http://localhost:8086' ],
'database' => 'telegraf',
'username' => 'telegraf',
'password' => 'metricsmetricsmetrics',
}
})
}

$inputs = hiera_hash('telegraf::inputs', {
$inputs = {
'cpu' => {
'percpu' => true,
'totalcpu' => true,
}
})
}
}
8 changes: 4 additions & 4 deletions templates/telegraf.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
debug = <%= @debug %>
quiet = <%= @quiet %>

<% if @outputs -%>
<% if @_outputs -%>
#
# OUTPUTS:
#
<% @outputs.sort.each do | output, options | -%>
<% @_outputs.sort.each do | output, options | -%>
[[outputs.<%= output %>]]
<% unless options == nil -%>
<% options.sort.each do | option, value | -%>
Expand All @@ -35,11 +35,11 @@
<% end -%>
<% end -%>

<% if @inputs -%>
<% if @_inputs -%>
#
# INPUTS:
#
<% @inputs.sort.each do | input, options | -%>
<% @_inputs.sort.each do | input, options | -%>
[[inputs.<%= input %>]]
<% unless options == nil -%>
<% options.sort.each do | option, value | -%>
Expand Down

0 comments on commit 627c93e

Please sign in to comment.