mustache template in dryrun mode does not work as expected

11 views
Skip to first unread message

HJ Ko

unread,
Mar 20, 2017, 12:35:01 PM3/20/17
to help-cfengine
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

Nick Anderson

unread,
Mar 20, 2017, 3:04:42 PM3/20/17
to HJ Ko, help-cfengine
Yes, this looks like a bug to me.


--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengine+unsubscribe@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages