im trying to generate a random number in puppet bolt.
I have tried this way:
function sot::getrand(
) >> Numeric {
$rannumber = rand(100)
$rannumber
}
the reason why Im trying to generate a random number its because I wanted to use it in the name of a file like this:
$sot_data_file = '/tmp/sotdata${sot::getrand()}'
I got an error trying to do this way:
"Evaluation Error: Unknown function: 'rand'. (file: /home/repos/bolt_f5afm/site/sot/functions/getrand.pp, line: 3, column: 16)",
Do you know guys if there is any way to do this in an easy way? im totally new at puppet.
Recommend implementing using a custom function. Under your bolt project, create the directory structure:
Create a file for the custom function
lib/puppet/functions/rand.rb
with the following code: