#!/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" content = template(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