example42 / puppet-splunk

Splunk Puppet Module
http://www.example42.com
Other
12 stars 29 forks source link

Use yum for custom installs #30

Open lindsay-apitalent opened 9 years ago

lindsay-apitalent commented 9 years ago

Could you switch to yum not rpm for custom installs? Then yum won't report package database altered outside of yum.

yum install

alvagante commented 9 years ago

PR welcomed

fleXible commented 8 years ago

Just build yourself a wrapper class to provide the yum repository and let puppet do the rest. Works like a charm for us:

# splunk_forwarder main class
#
class splunk_forwarder (
  $yumreposerver              = hiera('yumreposerver', 'localhost'),
  $install_forwarder          = hiera('splunk_forwarder::install_forwarder', false),
  $admin_password             = hiera('splunk_forwarder::admin_password', 'betterchangeme'),
  $indexer_servers            = hiera('splunk_forwarder::indexer_servers', [ 'indexer.corp.com:9997' ]),
  $deployment_server          = hiera('splunk_forwarder::deployment_server', ''),
  ) {

  $bool_install_forwarder       = str2bool($install_forwarder)
  $bool_activate_log_forwarding = str2bool($activate_log_forwarding)

  # sanitize variables
  validate_string($yumreposerver)
  validate_bool($bool_install_forwarder)
  validate_string($admin_password)
  validate_array($indexer_servers)
  validate_string($deployment_server)

  anchor { 'splunk_forwarder::begin': } ->
  yumrepo { 'splunk_forwarder':
    baseurl         => "http://${yumreposerver}/splunk_forwarder",
    descr           => 'Repository for splunk_forwarder',
    enabled         => 1,
    gpgcheck        => 0,
    metadata_expire => 1,
  } ->
  class { 'splunk':
      install           => 'forwarder',
      absent            => !$bool_install_forwarder,
      admin_password    => $admin_password,
      template_outputs  => 'splunk_forwarder/outputs.conf.erb',
      template_inputs   => 'splunk_forwarder/inputs.conf.erb',
      deployment_server => $deployment_server,
  } ->
  anchor { 'splunk_forwarder::end': }
}
alvagante commented 8 years ago

Thanks for sharing