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

CFEngine ignores conditionals in edit_template BEGIN/END blocks

    XMLWordPrintable

    Details

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

      Description

      Consider the following template file:

      <pre>
      $ 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.)
      </pre>

      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):

      <pre>
      $ 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.
      </pre>

      This is the bundle used for testing:

      <pre>
      $ 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"; }

      </pre>

      <pre>
      $ 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
      </pre>

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

      <pre>
      $ cf-agent --version
      CFEngine Core 3.5.0b2.38840ad
      </pre>

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: