On Tue, Jan 18, 2011 at 09:42:57AM -0500, Bas van der Vlies wrote:
>On 18-01-11 13:49, Jesse Becker wrote:
>> On Tue, Jan 18, 2011 at 04:48, Bas van der Vlies<b...@sara.nl>  wrote:
>>>> ## Report if we lost contact with our policy server for an hour
>>>> #
>>>> bundle agent cfengine3_check_server_connectivity
>>>> {
>>>> vars:
>>>>     "myhosts" slist =>    { hostsseen("1","notseen","address") };
>>>>
>>>> classes:
>>>>     "cfengine_no_connectivity"   expression =>    reglist("@(myhosts)",
>>>> escape("$(g.policyserver)"));
>>>>
>>>> reports:
>>>>     cfengine_no_connectivity::
>>>>      "Not seen cfengine3 policy server: $(g.policyserver) for at least a
>>>> hour";
>>>> }
>>>>
>>>>
>>>
>>> Just a warning for this bundle when i run in verbose mode i get strange
>>> messages like:
>>> cf3  !! Duplicate selection of value for variable "myhosts" in scope test
>>> cf3  !! Rule from /var/tmp/lastseen.cf at/before line 17
>>>
>>> multiple time. I have reported this:
>>> https://cfengine.com/bugtracker/view.php?id=448
>>>
>>> This is with a version cf3 from trunk
>>
>> I wonder....
>>
>> Does it go away if you write:
>>
>>
>> vars:
>>     "myhosts" slist =>   { hostsseen("1","notseen","address") }, policy =>  
>> 'free';
>>
>>
>> Alternately, if you use a convoluted construct like this?  This should
>> cause the hostseen() function and 'myhosts' variable to be evaluated
>> only once.
>>
>Thanks for tip. So we values change the key is to use the policy statement.
>  This is also useful for storage constructions.

I think so, yes.  Since vars: is called 3 times with each run of
cf-agent, the values returned will be *slightly* different each time.

As a matter of design, I wonder if it would make sense for certainly
built-in functions to either be automatically set "policy => 'free'". 
Users could always override the policy statement to be 'constant' if
they need it.


-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to