#!/usr/bin/ruby module Puppet::Parser::Functions newfunction(:template_with_check) do |args| tmpl = args[0] checkscript = args[1] # tmpfile = generate("mktemp /tmp/template.XXXXXX") tmpfile = "/tmp/template.tmp" # Retrieve the internal method name method = Puppet::Parser::Functions.function(:template) # Call it with the template name content = send(method, tmpl) File.open(tmpfile, 'a') {|fd| fd.puts content } if generate(checkscript tmpfile) # return(file(tmpfile)) return 0 end # return("Error: could not validate file") return 1 end end