Hi Nicholas,
Thanks for the help. I have a working promise file now, based on what you and
Nick Anderson suggested.
I wasn't able to get the following class definition to work:
"agents" expression => and(regcmp( "ag.*", "$(sys.host)" ), not("agent041"),
not("agent042"));
But I have a workaround in place and I don't have a proper test environment, so
I am messing with running promises... I really need to get a test system in
place.
I kept seeing errors like this:
cf3> /var/cfengine/inputs/new_agent.cf:8,92: function and() returns type string
but lhs requires class, near token ')'
cf3> /var/cfengine/inputs/new_agent.cf:8,92: function and() returns type string
but lhs requires class, near token ')'
Fatal cfengine error: Validation: function and() returns type string but lhs
requires class
cf-agent was not able to get confirmation of promises from cf-promises, so
going to failsafe
I am going to experiment when I get the chance.
Lisa
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nicolas Charles
Sent: Tuesday, February 07, 2012 10:22 AM
To: [email protected]
Subject: Re: CFEngine Help: Re: create class which is a superset of another
class
Hi Lisa !
>
>> But it seems to me that OR will not work with more than two choices
>> and in reality I want to merge more than two classes. I guess I
>> could use an AND in that case?
> Why would it not work? OR is a logical operation, it would work on any number
> of classes:
>
> "some_class" or => { "agents", "master", "dns_server",
> "web_server", "suse_9" };
>
>
Which version of CFEngine are you using ? I remember we had some issues on
3.1.4 with complex classes expression, that were not correctly evaluated, so it
could explain why you believe that you can OR more than twice
>> And I would like to do something fancier than naming all the hosts in
>> a class. Something like:
>>
>> "agents" expression => regcmp( "ag.*" , "${sys.host}");
>>
>> but I have two hosts that would match that expression and I want to
>> exclude them. Let's say they are agent041 and agent042.
> You could do this like Nick suggested, by explicitly excluding them, with
> something like this:
>
> "agents" expression => and(regcmp( "ag.*", "$(sys.host)" ),
> not("agent041"), not("agent042"));
>
>
You could also use class conditions to define classes :
classes:
!agent041.!agent042::
"agents" expression => regcmp( "ag.*" , "${sys.host}");
Or even a bit more complex with classes and ifvarclass:
classes:
!agent041.!agent042::
"agents"
expression => regcmp( "ag.*" , "${sys.host}"),
ifvarclass => "some_class_expression";
Best regards !
Nicolas
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine