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

added technology addon feature #26

Merged
merged 2 commits into from
Mar 8, 2016
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
65 changes: 65 additions & 0 deletions manifests/addon.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# Defined type: splunk::addon
#
# This define sets up a TA (Technology Addon) for Splunk. It (optionally)
# installed a package, and configures input forwarders in
# $SPLUNK_HOME/etc/apps/<app name>/local/inputs.conf
#
# Examples
#
# splunk::addon { 'search':
# package_manage => false,
# }
#
# splunk::addon::input { 'monitor:///var/log/messages':
# attributes => {
# 'index' => 'server_t',
# },
# }
#
# Alternatively you can feed inputs directly into splunk::addon using the
# inputs parameter (useful if you are configuring from Hiera)
#
#
# splunk::addon { 'search':
# package_manage => false,
# inputs => {
# 'monitor:///var/log/messages' => {
# 'attributes' => {
# 'index' => 'server_t',
# }
# }
# }
# }
#
define splunk::addon (
$splunk_home = '/opt/splunkforwarder',
$package_manage = true,
$package_name = undef,
$inputs = {},
) {


if ( $package_manage ) {
validate_string($package_name)
package { $package_name:
ensure => installed,
before => File["${splunk_home}/etc/apps/${name}/local"],
}
}

file { "${splunk_home}/etc/apps/${name}/local":
ensure => directory,
}

if $inputs {
concat { "splunk::addon::inputs_${name}":
path => "${splunk_home}/etc/apps/${name}/local/inputs.conf",
require => File["${splunk_home}/etc/apps/${name}/local"]
}

create_resources('splunk::addon::input', $inputs, {"addon" => $name })
}

}

17 changes: 17 additions & 0 deletions manifests/addon/input.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Private defined type callled by splunk::addon

define splunk::addon::input (
$addon,
$attributes={},
) {

assert_private()

concat::fragment { "splunk::addon::input::${addon}::${name}:":
target => "splunk::addon::inputs_${addon}",
content => template('splunk/addon/_input.erb'),
order => '10',
}
}


5 changes: 5 additions & 0 deletions manifests/forwarder.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
$forwarder_output = $splunk::params::forwarder_output,
$forwarder_input = $splunk::params::forwarder_input,
$create_password = $splunk::params::create_password,
$addons = {},
) inherits splunk::params {

$virtual_service = $splunk::params::forwarder_service
Expand Down Expand Up @@ -81,6 +82,10 @@
install_options => $splunk::params::forwarder_install_options,
tag => 'splunk_forwarder',
}

# Declare addons
create_resources('splunk::addon', $addons)

# Declare inputs and outputs specific to the forwarder profile
create_resources( 'splunkforwarder_input',$forwarder_input)
create_resources( 'splunkforwarder_output',$forwarder_output)
Expand Down
6 changes: 6 additions & 0 deletions templates/addon/_input.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[<%= @name %>]
<% @attributes.each do |key,val| -%>
<%= key %>=<%= val %>
<% end -%>