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

Move lookup_options to hiera #134

Merged
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
6 changes: 6 additions & 0 deletions data/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
lookup_options:
'telegraf::inputs':
merge: 'deep'
'telegraf::outputs':
merge: 'deep'
10 changes: 10 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
version: 5

defaults:
datadir: 'data'
data_hash: yaml_data

hierarchy:
- name: 'defaults'
path: 'defaults.yaml'
11 changes: 0 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@
$service_hasstatus = $telegraf::params::service_hasstatus
$service_restart = $telegraf::params::service_restart

$_outputs = lookup({
name => 'telegraf::outputs',
default_value => $outputs,
merge => deep,
})
$_inputs = lookup({
name => 'telegraf::inputs',
default_value => $inputs,
merge => deep,
})

contain telegraf::install
contain telegraf::config
contain telegraf::service
Expand Down
8 changes: 2 additions & 6 deletions templates/telegraf.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@
debug = <%= @debug %>
quiet = <%= @quiet %>

<% if @_outputs -%>
Copy link
Member Author

Choose a reason for hiding this comment

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

A hash is always truthy. I did consider changing it to unless @outputs.empty?, but I don't think there's any point. The defaults aren't empty, and does having no inputs or outputs make a lot of sense?

#
# OUTPUTS:
#
<%= require 'toml-rb'; TomlRB.dump({'outputs'=>@_outputs}) %>
<% end -%>
<%= require 'toml-rb'; TomlRB.dump({'outputs'=>@outputs}) %>

<% if @_inputs -%>
#
# INPUTS:
#
<%= require 'toml-rb'; TomlRB.dump({'inputs'=>@_inputs}) %>
<% end -%>
<%= require 'toml-rb'; TomlRB.dump({'inputs'=>@inputs}) %>