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

CFEngine ignores conditionals in edit_template BEGIN/END blocks



    • Type: Bug
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.0
    • Labels:


      Consider the following template file:

      $ cat TEST.tmpl
      Any file should contain this line.

      [%CFEngine BEGIN %]
      And this line as well.

      [%CFEngine variant:: %]
      But this line should appear only in the variant file.

      [%CFEngine END %]
      The end is always the same.

      [%CFEngine variant:: %]
      (although variant should have this as well.)

      When this template is expanded into a file, I would expect the
      "variant" line to be skipped, as no "variant" class is defined.
      Instead it appears that CFEngine ignores the `[%CFEngine variant:: %]`
      conditional within the BEGIN/END block (the one outside is obeyed):

      $ cat /tmp/target
      Any file should contain this line.

      And this line as well.

      But this line should appear only in the variant file.

      The end is always the same.

      This is the bundle used for testing:

      $ cat TEST.cf
      body common control
      bundlesequence =>

      { "test" }


      bundle agent test

      { methods: "test" usebundle => bug_expanding_templates; reports: cfengine:: "Running a test"; }

      bundle agent bug_expanding_templates

      { files: "/tmp/target" create => "true", edit_defaults => empty, edit_template => "/home/rmurri/gc3/cfengine/masterfiles/TEST.tmpl"; }

      body edit_defaults empty

      { empty_file_before_editing => "true"; edit_backup => "false"; max_file_size => "300000"; }


      $ cf-agent -I -f ./TEST.cf
      2013-05-21T15:12:25+0200 info: This agent is not bootstrapped
      2013-05-21T15:12:25+0200 info: Running full policy integrity checks
      2013-05-21T15:12:26+0200 info: /test/methods/'test'/bug_expanding_templates/files/'/tmp/target': Created file /tmp/target, mode = 0600

      2013-05-21T15:12:26+0200 info: /test/methods/'test'/bug_expanding_templates/files/'/tmp/target': Edit file /tmp/target
      2013-05-21T15:12:26+0200 notice: R: Running a test

      I'm running the current 3.5.x code from GitHub:

      $ cf-agent --version
      CFEngine Core 3.5.0b2.38840ad




            • Assignee:
              a10025 Volker Hilsheimer (Inactive)
              riccardomurri Riccardo Murri
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: