Skip to content
Open
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
53 changes: 15 additions & 38 deletions manifests/inputs.pp
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
# splunk::inputs should be called to manage your splunk inputs.conf
# by default outputs.conf will be placed in $splunkhome/etc/system/local/
# === Parameters
#
# [input_hash]
# Nested Hash used to define monitored inputs. Sorry, I couldn't think of
# a better way to do this :/
# The format is:
# { 'input title' => { 'setting' => 'value' } }
# splunk::inputs should be called to start management your splunk inputs.conf.
# By default inputs.conf will be placed in $splunkhome/etc/system/local/
# To add entries to the file, use splunk::inputs::create
#
# class { 'splunk::inputs':
# input_hash => { 'script://./bin/sshdChecker.sh' => {
# disabled => 'true',
# index => 'os',
# interval => '3600',
# source => 'Unix:SSHDConfig',
# sourcetype => 'Unix:SSHDConfig'},
# 'script://./bin/sshdChecker.sh2' => {
# disabled => 'true2',
# index => 'os2',
# interval => '36002',
# source => 'Unix:SSHDConfig2',
# sourcetype => 'Unix:SSHDConfig2'}
# }
# }
# === Parameters
# $path allows you to override the default location of inputs.conf
#
class splunk::inputs (
$path = "${::splunk::splunkhome}/etc/system/local",
$input_hash = { }
) {
# Validate hash
if ( $input_hash ) {
if !is_hash($input_hash){
fail("${input_hash} is not a valid hash")
}
}
$input_title = keys($input_hash)
class splunk::inputs ($path = "${::splunk::splunkhome}/etc/system/local") {

file { "${path}/inputs.conf":
ensure => file,
concat {"${path}/inputs.conf":
owner => 'splunk',
group => 'splunk',
mode => '0644',
require => Class['splunk::install'],
notify => Class['splunk::service'],
notify => Class['splunk::service']
}

concat::fragment {"Inputs ${name} (Default + FQDN)":
target => "${path}/inputs.conf",
order => '00',
content => template('splunk/opt/splunk/etc/system/local/inputs.conf.erb'),
require => Class['splunk::install'],
notify => Class['splunk::service']
}
}
45 changes: 45 additions & 0 deletions manifests/inputs/create.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# splunk::inputs::create allows you to register new inputs.
#
# === Parameters
#- The resource name is used as the input title in inputs.conf
#- $content should be a hash containing what you want to apply to the input
#- $order is optional, it allows you to set input position in the resulting file
#- $path functions the same it does in splunk::inputs.
#
# === Example
#- Puppet code
# ::splunk::inputs::create {'script://./bin/sshdChecker.sh':
# $content => {
# disabled => 'true',
# index => 'os',
# interval => '3600',
# source => 'Unix:SSHDConfig',
# sourcetype => 'Unix:SSHDConfig'
# }
# }
#
#- Resulting input config
# [script://./bin/sshdChecker.sh]
# disabled = true
# index = os
# interval = 3600
# source = Unix:SSHDConfig
# sourcetype = Unix:SSHDConfig
#
define splunk::inputs::create(
$content,
$order = '10',
$path = "${::splunk::splunkhome}/etc/system/local"
) {
# Validate hash
if !is_hash($content){
fail("${content} is not a valid hash")
}

concat::fragment {"Inputs ${name}":
target => "${path}/inputs.conf",
order => $order,
content => template('splunk/opt/splunk/etc/system/local/inputs_create.erb'),
notify => Class['splunk::service']
}
}
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"description": "This Module manages Splunk Indexer, Search Heads, SLF and Heavy Forwarders as well as a number of apps",
"dependencies": [
{"name":"puppetlabs/inifile","version_requirement":">=1.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">=3.2.0"}
{"name":"puppetlabs/stdlib","version_requirement":">=3.2.0"},
{"name":"puppetlabs/concat","version_requirement":"=1.2.2"}
],
"operatingsystem_support": [
{
Expand Down
7 changes: 0 additions & 7 deletions templates/opt/splunk/etc/system/local/inputs.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@
[default]
host = <%= @fqdn %>

<% @input_title.sort.each do |inputname| -%>
[<%= inputname -%>]
<% @input_hash[inputname].sort.each do |key,value| -%>
<%= key -%> = <%= value %>
<% end %>
<% end %>

4 changes: 4 additions & 0 deletions templates/opt/splunk/etc/system/local/inputs_create.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[<%= name -%>]
<% @content.sort.each do |key,value| -%>
<%= key -%> = <%= value %>
<% end %>