Forum: CFEngine Help
Subject: Re: False report of "no constrants" in constrained classes promises.
Author: mark
Link to topic: https://cfengine.com/forum/read.php?3,27501,27506#msg-27506
On 09/23/2012 02:42 AM, Aleksey Tsalolikhin wrote:
> 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" };
>
> }
>
>
> }}}
>
>
Hi Aleksey, here are my suggestions.
>
> 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.
That's true but there are no constraints that determine the class. It's like
writing
classes:
solaris::
"webfarm"; # missing right hand side definition
I think what you are trying to write is this:
vars:
"webservers" slist => { "web01", "web02", "web03" };
classes:
"webclass" or => { "@(webservers)" };
Then, e.g.
reports:
webclass:: "something or other";
or
"something or other" ifvarclass => "webclass";
This satisfies all of the points above. You slipped into thinking imperatively,
I think, but there is no need to struggle with this.
M
--
CTO and Founder
CFEngine
http://www.cfengine.com
http://www.markburgess.org
Twitter: @markburgess_osl, @CFEngine_news
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine