diff --git a/manifests/addon.pp b/manifests/addon.pp index d4f11a42..d347a08f 100644 --- a/manifests/addon.pp +++ b/manifests/addon.pp @@ -35,38 +35,76 @@ define splunk::addon ( Optional[Stdlib::Absolutepath] $splunk_home = undef, Boolean $package_manage = true, + Optional[String[1]] $splunkbase_source = undef, Optional[String[1]] $package_name = undef, Hash $inputs = {}, ) { - include 'splunk::params' + include splunk::params + + if defined('splunk::forwarder') { + $mode = 'forwarder' + } else { + $mode = 'enterprise' + } if $splunk_home { $_splunk_home = $splunk_home } else { - $_splunk_home = $splunk::params::forwarder_homedir + case $mode { + 'forwarder': { $_splunk_home = $splunk::params::forwarder_homedir } + 'enterprise': { $_splunk_home = $splunk::params::enterprise_homedir } + } } if $package_manage { - package { $package_name: - ensure => installed, - before => File["${_splunk_home}/etc/apps/${name}/local"], + if $splunkbase_source { + $archive_name = $splunkbase_source.split('/')[-1] + archive { $name: + path => "${splunk::params::staging_dir}/${archive_name}", + source => $splunkbase_source, + extract => true, + extract_path => "${_splunk_home}/etc/apps", + creates => "${_splunk_home}/etc/apps/${name}", + cleanup => true, + before => File["${_splunk_home}/etc/apps/${name}/local"], + } + } else { + package { $package_name: + ensure => installed, + before => File["${_splunk_home}/etc/apps/${name}/local"], + } } } - file { "${_splunk_home}/etc/apps/${name}/local": - ensure => directory, - } + 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"], + unless $inputs.empty { + $inputs.each |$section, $attributes| { + $attributes.each |$setting, $value| { + case $mode { + 'forwarder': { + splunkforwarder_input { "${name}_${section}_${setting}": + section => $section, + setting => $setting, + value => $value, + context => "apps/${name}/local", + require => File["${_splunk_home}/etc/apps/${name}/local"], + } + } + 'enterprise': { + splunk_input { "${name}_${section}_${setting}": + section => $section, + setting => $setting, + value => $value, + context => "apps/${name}/local", + require => File["${_splunk_home}/etc/apps/${name}/local"], + } + } + } + } } - - create_resources('splunk::addon::input', $inputs, {'addon' => $name }) } - } diff --git a/manifests/addon/input.pp b/manifests/addon/input.pp deleted file mode 100644 index 9d4e0e6d..00000000 --- a/manifests/addon/input.pp +++ /dev/null @@ -1,17 +0,0 @@ -# Private defined type called 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', - } -} - - diff --git a/templates/addon/_input.erb b/templates/addon/_input.erb deleted file mode 100644 index 275d504e..00000000 --- a/templates/addon/_input.erb +++ /dev/null @@ -1,6 +0,0 @@ -[<%= @name %>] -<% @attributes.each do |key,val| -%> -<%= key %>=<%= val %> -<% end -%> - -