forked from voxpupuli/puppet-logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a logstash::templatefile defined type to support adding
index templates for use with the elasticsearch output plugin. Fixes voxpupuli#264
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} | ||
} |