Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2600

Classes based on promise outcome should work for warn action with mustache templates

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.10.0
    • Fix Version/s: 3.12.1, 3.13.0
    • Component/s: Promise type: files
    • Labels:
      None
    • Steps to reproduce:
      Acceptance/unit test attached

      Description

      When a promise has action set to warn classes bodies should still be able to define classes based on the promise outcome.

      Mustache File (/tmp/main.mustache)

      Running CFEngine {{{sys.cf.version}}} on {{sys.date}}
      

      Example/Test policy

        bundle agent main
        {
          files:
      
            "/tmp/$(this.bundle)-present.txt"
              create => "true";
            "/tmp/$(this.bundle)-absent.txt"
              delete => tidy;
      
      # This promise SHOULD produce classes
            "/tmp/$(this.bundle)-present.txt"
              template_method => "mustache",
              edit_template => "/tmp/$(this.bundle).mustache",
              action => policy("warn"),
              classes => results("bundle", "$(this.bundle)_template_present_target");
      
      # This promise DOES produce classes (as expected)
            "/tmp/$(this.bundle)-absent.txt"
              template_method => "mustache",
              edit_template => "/tmp/$(this.bundle).mustache",
              action => policy("warn"),
              classes => results("bundle", "$(this.bundle)_template_absent_target");
      
      
          vars:
            "found" slist => classesmatching("$(this.bundle)_.*");
      
      
          reports:
            "$(this.promise_filename) Pass"
              if => "template_present_target_reached.template_absent_target_reached";
      
            "$(this.promise_filename) FAIL"
              unless => "template_present_target_reached.template_absent_target_reached";
      
            DEBUG|EXTRA::
              "Found class '$(found)'";
        }
      

      Example output from 3.10.0:

      : R: /home/nickanderson/org/cfengine3-5632OPl FAIL
      

        Attachments

          Activity

            People

            • Assignee:
              olehermanse Ole Herman Schumacher Elgesem
              Reporter:
              a10042 Nick Anderson
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel