> Does CFEngine provide tool to render a mustache template?
No, CFEngine doesn't have a standalone tool to render mustache. This online demo
is a good place to quickly prototype a simple template and data set.
Another option is to use a stand-alone policy file.
Name the file whatever you like. It looks for json in a file named
the same
suffixed with .json, it looks for a mustache template named the
same suffixed
with .mustache, and it renders to a file named the same suffixed
with .txt.
So if you name the file /tmp/standalone-mustache.cf it will look
for
/tmp/standalone-mustache.cf.json,
/tmp/standalone-mustache.cf.mustache, and
render /tmp/standalone-mustache.cf.txt.
# Standalone policy file for prototyping mustache
bundleagentmain{vars:"datafile"string=>"$(this.promise_filename).json";"template"string=>"$(this.promise_filename).mustache";"target"string=>"$(this.promise_filename).txt";"data"data=>readjson($(datafile),inf);files:"$(target)"create=>"true",handle=>"render_target",template_method=>"mustache",edit_template=>"$(template)",template_data=>@(data);reports:"JSON data file missing. Looking for '$(datafile)'"if=>not(fileexists($(datafile)));"Mustache template missing. Looking for '$(template)'"if=>not(fileexists($(template)));"$(target):"printfile=>cat($(target)),depends_on=>{"render_target"};}bodyprintfilecat(file)# @brief Report the contents of a file
# @param file The full path of the file to report
{file_to_print=>"$(file)";number_of_lines=>"inf";}