Hi,
if I use mustache template in warn-mode, the outcome classes are not set as expected.
I'v saved the example as /root/exapmle.cf:
body common control
{
inputs => {
"/var/cfengine/inputs/lib/common.cf",
};
}
bundle agent example
{
vars:
"result_classes" slist => classesmatching("result.*");
files:
"/tmp/example.cf.output"
template_method => 'mustache',
edit_template => "/root/example.cf",
action => policy("warn"),
classes => classes_generic("result");
reports:
"RESULT: $(result_classes)";
}
1) First run:
[root@vphub ~]# cf-agent -KI -f ./example.cf -b example
info: Using command line specified bundlesequence
error: Promised to edit '/tmp/example.cf.output', but file does not exist
R: RESULT: result_reached
R: RESULT: result_not_kept
R: RESULT: result_failed
R: RESULT: result_error
R: RESULT: result_not_ok
Works as expected.
2) I'll create the file for cfengine, and rerun:
[root@vphub ~]# touch /tmp/example.cf.output ; cf-agent -KI -f ./example.cf -b example
info: Using command line specified bundlesequence
warning: Need to render '/tmp/example.cf.output' from mustache template '/root/example.cf' but policy is dry-run
[root@vphub ~]#
I'm seeing no "result" classes, should'nt they be set?
3) Finally, I ensure that the promise is met and rerun:
Code hier ei[root@vphub ~]# cp /root/example.cf /tmp/example.cf.output ; cf-agent -KI -f ./example.cf -b example
info: Using command line specified bundlesequence
R: RESULT: result_reached
R: RESULT: result_kept
R: RESULT: result_ok
That works again like expected.
4) When I changed "template_method" from "mustache" to "cfengine", the output is like expected:
[root@vphub ~]# rm /tmp/example.cf.output[root@vphub ~]# touch /tmp/example.cf.output ; cf-agent -KI -f ./example.cf -b example
info: Using command line specified bundlesequence
warning: File content wants to change from from/to full/empty but only a warning promised
[...]
warning: Should edit file '/tmp/example.cf.output' but only a warning promised
R: RESULT: result_reached
R: RESULT: result_not_kept
R: RESULT: result_failed
R: RESULT: result_error
R: RESULT: result_not_ok
Is it a bug that the result*-classes in run 2 are not set?
cfengine version: 3.10.0
HJ