Sha256: c2107089c9942927fcb0929b1873b3232ed6c1e8665ad2a8f6e7305bf8520ca1
Contents?: true
Size: 602 Bytes
Versions: 16
Compression:
Stored size: 602 Bytes
Contents
require 'digest/md5' Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc => "Generates random numbers based on the node's fqdn. Generated random values will be a range from 0 up to and excluding n, where n is the first parameter. The second argument specifies a number to add to the seed and is optional, for example: $random_number = fqdn_rand(30) $random_number_seed = fqdn_rand(30,30)") do |args| max = args.shift.to_i seed = Digest::MD5.hexdigest([self['::fqdn'],args].join(':')).hex Puppet::Util.deterministic_rand(seed,max) end
Version data entries
16 entries across 16 versions & 1 rubygems