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.
implement content param for file resource
this is a PR for [issue](voxpupuli#222), I tested it with puppet 3.8.1 on centos7, it is working fine.
- Loading branch information
Tim Meusel
authored and
Tim Meusel
committed
Jun 10, 2015
1 parent
4180112
commit a563a7d
Showing
1 changed file
with
27 additions
and
12 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 |
---|---|---|
|
@@ -39,25 +39,40 @@ | |
# * Richard Pijnenburg <mailto:[email protected]> | ||
# | ||
define logstash::patternfile ( | ||
$source, | ||
$content = '', | ||
$source = '', | ||
$filename = '', | ||
){ | ||
|
||
validate_re($source, '^puppet://', 'Source must be from a puppet fileserver (begin with puppet://)' ) | ||
|
||
if ($content == '') and ($source == '') { | ||
fail('please specify $content or $source') | ||
} | ||
if ($content != '') and ($source != '') { | ||
fail("you provided \$content with ${content} and \$source with ${source}, please only provide one of them") | ||
} | ||
unless ($source == ''){ | ||
validate_re($source, '^puppet://', 'Source must be from a puppet fileserver (begin with puppet://)' ) | ||
} | ||
$patterns_dir = "${logstash::configdir}/patterns" | ||
|
||
$filename_real = $filename ? { | ||
'' => inline_template('<%= @source.split("/").last %>'), | ||
default => $filename | ||
} | ||
|
||
file { "${patterns_dir}/${filename_real}": | ||
ensure => 'file', | ||
owner => $logstash::logstash_user, | ||
group => $logstash::logstash_group, | ||
mode => '0644', | ||
source => $source, | ||
unless ($content == ''){ | ||
file { "${patterns_dir}/${filename_real}": | ||
ensure => 'file', | ||
owner => $logstash::logstash_user, | ||
group => $logstash::logstash_group, | ||
mode => '0644', | ||
content => $content, | ||
} | ||
} else { | ||
file { "${patterns_dir}/${filename_real}": | ||
ensure => 'file', | ||
owner => $logstash::logstash_user, | ||
group => $logstash::logstash_group, | ||
mode => '0644', | ||
source => $source, | ||
} | ||
} | ||
|
||
} |