Forum: CFEngine Help
Subject: Re: Methods and default variables
Author: bbomgardner
Link to topic: https://cfengine.com/forum/read.php?3,23009,23040#msg-23040

Oh, I see.  I suppose you must use an array to pass the variables, as cfengine 
enforces formal and actual parameters to match.

So, this works but it looks pretty bad.  What do you think?


body common control {
  bundlesequence => { test };
}

bundle agent test {
vars:
  "stuff" string => "one";
  "stuff" string => "five";

methods:
  "any" usebundle => foo("test.stuff");
}

bundle agent foo(stuff) {
vars:
  "defaults" string => "one";
  "defaults" string => "two";
  "defaults" string => "three";
  "d" slist => getindices("defaults");

classes:
  "$(d)_was_passed" not => regcmp("$(defaults[$(d)])", "$($(stuff)[$(d)])");

reports:
  linux::
    "Passed: $(d): $($(stuff)[$(d)])",
      ifvarclass => "$(d)_was_passed";
    "Default: $(d): $(defaults[$(d)])",
      ifvarclass => "!$(d)_was_passed";
}


_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to