Defined Type: logstash::configfile

Defined in:
manifests/configfile.pp

Overview

This type represents a Logstash pipeline configuration file.

Parameters are mutually exclusive. Only one should be specified.

Examples:

Create a config file content with literal content.


logstash::configfile { 'heartbeat':
  content => 'input { heartbeat {} }',
}

Render a config file from a template.


logstash::configfile { 'from-template':
  template => 'site-logstash-module/pipeline-config.erb',
}

Copy the config from a file source.


logstash::configfile { 'apache':
  source => 'puppet://path/to/apache.conf',
}

Create a config at specific location. Good for multiple pipelines.


logstash::configfile { 'heartbeat-2':
  content => 'input { heartbeat {} }',
  path    => '/usr/local/etc/logstash/pipeline-2/heartbeat.conf'
}

Parameters:

  • content (String) (defaults to: undef)

    Literal content to be placed in the file.

  • template (String) (defaults to: undef)

    A template from which to render the file.

  • source (String) (defaults to: undef)

    A file resource to be used for the file.

  • path (String) (defaults to: undef)

    An optional full path at which to create the file.

Author:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'manifests/configfile.pp', line 44

define logstash::configfile (
  $content = undef,
  $source = undef,
  $template = undef,
  $path = undef,
) {
  include logstash

  $owner = 'root'
  $group = $logstash::logstash_group
  $mode  = '0640'
  $require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
  $tag = ['logstash_config'] # So that we notify the service.

  if($template) { $config = template($template) }
  elsif($content) { $config = $content }
  else { $config = undef }

  if($path) { $config_file = $path }
  else { $config_file = "${logstash::config_dir}/conf.d/${name}" }

  if($config) {
    file { $config_file:
      content => $config,
      owner   => $owner,
      group   => $group,
      mode    => $mode,
      require => $require,
      tag     => $tag,
    }
  }
  elsif($source) {
    file { $config_file:
      source  => $source,
      owner   => $owner,
      group   => $group,
      mode    => $mode,
      require => $require,
      tag     => $tag,
    }
  }
}