Forum: CFEngine Help
Subject: Re: Using dist for random selections
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,24500,24504#msg-24504

I tried using randomint instead but got some unexpected results.

neil@ettin ~/.cfagent/inputs $ cat test.cf
body common control {

        bundlesequence => {
                "main",
        };

        inputs => { "cfengine_stdlib.cf" };
}

bundle agent main{

vars:

        "rand" int => randomint(1,100);

classes:

        "heads" expression => islessthan("$(rand)","51");
        "tails" expression => isgreaterthan("$(rand)","50");

reports:

        heads::
                "heads: $(rand) < 51";

        tails::
                "tails: $(rand) > 50";
}

neil@ettin ~/.cfagent/inputs $ for I in $(seq 1 10); do cf-agent -Kf ./test.cf; 
done
R: heads: 51 < 51  ????
R: tails: 53 > 50
R: tails: 84 > 50
R: heads: 13 < 51
R: tails: 86 > 50
R: heads: 35 < 51
R: tails: 3 > 50 ????
R: heads: 17 < 51
R: heads: 62 < 51 ????
R: tails: 87 > 50
R: heads: 47 < 51
R: tails: 58 > 50


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

Reply via email to