Skip to content

Commit

Permalink
Add a logstash::templatefile defined type to support adding
Browse files Browse the repository at this point in the history
index templates for use with the elasticsearch output plugin.

Fixes voxpupuli#264
  • Loading branch information
joshuar committed Apr 19, 2017
1 parent a01d3c0 commit 48ed09c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions manifests/templatefile.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This type represents a Logstash template file.
#
# Parameters are mutually exclusive. Only one should be specified.
#
# @param [String] template
# A template from which to render the file.
#
# @param [String] source
# A file resource to be used for the file.
#
# @example Render a Logstash template from a erb template.
#
# logstash::templatefile { 'my-template':
# template => 'site-logstash-module/my-template.erb',
# }
#
# @example Copy the template from a file source.
#
# logstash::templatefile { 'my-template':
# source => 'puppet://path/to/my-template.json',
# }
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::templatefile(
$source = undef,
$template = undef,
)
{
include logstash

$path = "${logstash::config_dir}/templates/${name}.json"
$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){
file { $path:
content => template($template),
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
elsif($source){
file { $path:
source => $source,
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
}

0 comments on commit 48ed09c

Please sign in to comment.