blob: e075320597188e0d255d234cb23365c18c8402e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
module Puppet::Parser::Functions
require 'erb'
newfunction(:multi_source_template, :type => :rvalue) do |args|
contents = nil
environment = compiler.environment
sources = args
sources.each do |file|
Puppet.debug("Looking for #{file} in #{environment}")
if filename = Puppet::Parser::Files.find_template(file, environment.to_s)
wrapper = Puppet::Parser::TemplateWrapper.new(self)
wrapper.file = file
begin
contents = wrapper.result
rescue => detail
raise Puppet::ParseError, "Failed to parse template %s: %s" % [file, detail]
end
break
end
end
raise Puppet::ParseError, "multi_source_template: No match found for files: #{sources.join(', ')}" if contents == nil
contents
end
end
|