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

Modularise inputs_hash so we can declare them from more than one place! #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Nuxij
Copy link
Contributor

@Nuxij Nuxij commented Jan 15, 2016

This change moves away from the single-declaration inputs_hash, allowing us to define each input individually. It uses puppetlabs-concat to do it.

Old Style:

# To initialise and add all inputs. Can only be declared once.
class {'::splunk::inputs':
  input_hash => {
    'monitor:///var/log/httpd/*error.log' => {
      disabled   => false,
      followTail => '0',
      sourcetype => 'apache_error',
      index      => 'myindex'
    }
  }
}

New Style:

# To initialise. Can only be declared once.
class {'::splunk::inputs':}

# To add an input. Can be declared multiple times!
::splunk::inputs::create {'monitor:///var/log/httpd/*error.log':
  content => {
    disabled   => false,
    followTail => '0',
    sourcetype => 'apache_error',
    index      => 'myindex'
  }
}

@TheHob
Copy link

TheHob commented Feb 11, 2016

I would actually like to see this further modularized to support something like this:
create_resources('::splunk::conf_file', $any_hash)

Where the target file, section headings and stanza values can be specified as inputs ($any_hash) to the defined resource. In other words, not just for inputs, but for any config file, any stanza. Puppet's inifile module may be more appropriate for this.

@Nuxij
Copy link
Contributor Author

Nuxij commented Feb 11, 2016

I agree @TheHob, I will take a look at extending it further.

I did consider the inifile module but I'd already completed my work by that point so I didn't bother. I think it will be a more succinct approach so I'll give that a look too.

@TheHob
Copy link

TheHob commented Feb 11, 2016

If I have the time I was thinking of doing something like this, which is why your PR caught my eye. I'm definitely a +1 for extending this the way you're headed.

@TheHob
Copy link

TheHob commented Feb 11, 2016

To give you an idea of where I was headed, here's what I'm using in my splunk puppet profile:

define splunk_profile::resources::conf_file (
  $config_source,
 # Accept and gather any template variables from a hash
  $template_variables = {}
) {

  # Defaults
  File {
    owner   => 'splunk',
    group   => 'splunk',
    recurse => true,
    require => Class['::splunk::install'],
    notify  => Class['splunk::service'],
  }

  # File or template
  if $config_source =~ /^puppet:\/\// {
    file { $name:
      source  => $config_source
    }
  }
  else {
    file { $name:
      content => template("${config_source}")
    }
  }
}

YAML/hashes then look something like this:

splunk_profile::resources::config_files:
  /opt/splunk/etc/splunk-launch.conf:
    config_source: 'splunk_profile/splunk-launch.conf.erb'
    template_variables:
      splunk_db: "/somedir/%{hostname}"
  /opt/splunk/etc/system/local/authentication.conf:
    config_source:"puppet:///modules/splunk_profile/config/authentication.conf"

I'd like to meld the stanza-level stuff that you're doing in your PR (based on indexes.pp) with the source/target flexibility of the resource above. inifile would be icing on the cake.

@Nuxij
Copy link
Contributor Author

Nuxij commented Feb 11, 2016

Ok I'll take a crack at it :)

@tfhartmann
Copy link
Contributor

Very cool! Thanks guys!

On Feb 11, 2016, at 1:00 PM, Joe Eaves [email protected] wrote:

Ok I'll take a crack at it :)


Reply to this email directly or view it on GitHub #73 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants