Skip to content

Commit

Permalink
implement content param for file resource
Browse files Browse the repository at this point in the history
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.
39 changes: 27 additions & 12 deletions manifests/patternfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

}

0 comments on commit a563a7d

Please sign in to comment.