On Mon, Jul 2, 2012 at 2:31 PM, Mark Burgess <m...@cfengine.com> wrote:
> Ah, that sounds like a bug/unanticipated issue. Please file a report.

Done: issue 1208.

For the record, I've found a workaround:

1- instead of defining classes in the `classes:` section, call a
bundle of type "common" from `methods:` to define global classes;
2- move the `files:` promise that should `edit_template` into a
separate bundle (again) and call it from `methods:`.

The latter is needed because otherwise the `files:` promise is
considered already verified in the second iteration of the main bundle
(i.e., after the "common" one has been evaluated) and thus the
template is not expanded again.

Example code below.

## Example .cf:

bundle agent test(flag) {
  vars:
    "templatefile" string => "$(sys.workdir)/masterfiles/test.tmpl";

  methods:
    "1" usebundle => _test_define_classes("$(flag)");
    "2" usebundle => _test_edit_template("$(templatefile)");
}

bundle common _test_define_classes(flag) {
  classes:
    "test_class"  expression => strcmp("$(flag)", "true");
}

bundle agent _test_edit_template(templatefile) {
  files:
    "/tmp/test"
      create => "true",
      edit_defaults => empty,
     edit_template => "$(templatefile)";
}


bundle agent main {
  methods:
    "test" usebundle => test("true");
}

## Template file:

[%CFEngine test_class:: %]
This part should now be included.

[%CFEngine Hr14:: %]
It's 2 o'clock.
(This part appears at the right time.)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to