Situation:  I want to target a promise to a certain group of servers.
However I want to
abstract the elements of that group from the promises that target that
group, so that
when I add an element to that group, I only need to update *one*
promise, the one
enumerating that group.


(Let's assume my hosname is "web01".  The list is { "web01", "web02", "web03" }:


{{{


bundle common global_vars {

     vars:
        "webservers"
           slist => { "web01", "web02", "web03" };

}


}}}




Attempt 1:  Loop over the list of server names, checking if any match
the current context.
FAIL.  3.3.5 complains "No constraints for class promise webfarm":

{{{
bundle common global_classes {

   classes:

       "webfarm"

           ifvarclass => canonify("$(global_vars.webservers)");

}

}}}

The body of a promise details and constrains its nature.  This promise
is constrained by the ifvarclass attribute.


Attempt 2: use a function to see if my hostname matches any element in
slist webservers.

{{{

}bundle common global_classes {

classes:

  "webfarm"
      expression => reglist("@(global_vars.webservers)", escape("$(sys.host)"));

}

}}}

The 2nd way is has a higher syntax to signal ratio, with an extra
function and an extra variable, which obscures my intention (compared
to the concise 1st way).

I've opened ticket 1220 to track the issue of CFEngine reporting "no
constraints" on a constrained promise.

Thank you.

Yours fondly,
-at
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to