Forum: Cfengine Help
Subject: randomint issue
Author: Justin
Link to topic: https://cfengine.com/forum/read.php?3,17846,17846#msg-17846

The following use of randomint() isn’t working as I’d hoped. Is this a Cfengine 
bug or some misunderstanding on my part?


bundle agent random_numbers {
    vars:

        "indices" slist => {
             "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
        };

        "int$(indices)" int => randomint(0, 100);

    reports:

        cfengine_3::

           "int$(indices) = $(int$(indices))";

}



This yields output like this:


R: int00 = 42
R: int01 = 42
R: int02 = 42
R: int03 = 42
R: int04 = 42
R: int05 = 42
R: int06 = 42
R: int07 = 42
R: int08 = 42
R: int09 = 42



I’d expected randomint() to be called for each new variable. Perhaps the seed 
isn’t regenerated when the variable creation is within iteration rather than a 
completely new variable definition each time. I did a different test with 
completely distinct variables and the randomness seemed okay.

FWIW, I was just trying to test the randomness of randomint() due to seemingly 
less randomness than I’d expect in a way I’m using it within my policy.

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

Reply via email to