FWIW, for scalability I'd probably use $(sys.uqhost) to ensure that classmatch 
is not matching against another class that may exist and just happens to look 
like a valid hostname.

classes:
  "svxx" expression => regcmp("sv[0-9]{2}", "$(sys.uqhost)"); 

Justin

-----Original Message-----
From: help-cfengine-boun...@cfengine.org 
[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Erlend Leganger
Sent: Wednesday, April 21, 2010 3:02 AM
To: Cfengine help
Subject: Re: Matching host names by regexp

Perfect, why didn't I think of that - nice and simple. With this and a
more precise (and less readable) regexp, I now have the following:

classes:
   "svxx" expression => classmatch("sv[0-9]{2}"); #sv00, sv01, ..., sv99

Thanks,
Erlend



On 21 April 2010 08:57, Mark Burgess <mark.burg...@iu.hio.no> wrote:
>
> Sorry, I forgot to remove a {
>
> classes:
>    "svxx" expression => classmatch("sv..");
>
> Mark Burgess wrote:
>> Oh, I didn't notice that. But why not simply write
>>
>> classes:
>>    "svxx" expression =>{classmatch("sv..");
>>
>> Erlend Leganger wrote:
>>> I guess it's the and-any construct that looks strange to me, it's like
>>> writing a boolean expression with an "and True" at the end:
>>>
>>> if ($condition && 1){
>>>   &do_something;
>>> }
>>>
>>> But if this is the best way, I won't complain.
>>>
>>> - Erlend
>>>
>>> On 21 April 2010 07:19, Mark <m...@iu.hio.no> wrote:
>>>> Why do you say this is convoluted? I think it looks just fine
>>>>
>>>>
>>>> Mark
>>>>
>>>>
>>>> On 21 Apr 2010, at 07:07, Erlend Leganger <erlend.legan...@gmail.com> 
>>>> wrote:
>>>>
>>>>> I have some servers named sv01, sv02, sv03, ... which I need a class
>>>>> for in cf3 community 3.0.2. I have come up with this:
>>>>>
>>>>> classes:
>>>>>   "svxx" and =>{classmatch("sv.."),any};
>>>>>
>>>>> so that I later can do for example:
>>>>>
>>>>> files:
>>>>>   svxx::
>>>>>      "/etc/passwd"
>>>>>         handle=>"update_passwd",
>>>>>         ...
>>>>>
>>>>> I don't remember how I came up with this construct (probably by trial
>>>>> and error until it clicked) - it looks kind of convoluted.
>>>>>
>>>>> What is the best way to do this?
>>>>>
>>>>> - Erlend
>>>>> _______________________________________________
>>>>> Help-cfengine mailing list
>>>>> Help-cfengine@cfengine.org
>>>>> https://cfengine.org/mailman/listinfo/help-cfengine
>>> _______________________________________________
>>> Help-cfengine mailing list
>>> Help-cfengine@cfengine.org
>>> https://cfengine.org/mailman/listinfo/help-cfengine
>>
>
> --
> Mark Burgess
>
> -------------------------------------------------
> Professor of Network and System Administration
> Oslo University College, Norway
>
> Personal Web: http://www.iu.hio.no/~mark
> Office Telf : +47 22453272
> -------------------------------------------------
>
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

This electronic communication and any attachments may contain confidential and 
proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an 
agent or employee 
responsible for delivering this communication to the intended recipient, or if 
you have received 
this communication in error, please do not print, copy, retransmit, disseminate 
or 
otherwise use the information. Please indicate to the sender that you have 
received this 
communication in error, and delete the copy you received. DigitalGlobe reserves 
the 
right to monitor any electronic communication sent or received by its 
employees, agents 
or representatives.

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

Reply via email to