Sha256: 830707198b9203a4896673837609b0a4b1d4a2ac016ade0cbf8c89d29def3ae5

Contents?: true

Size: 561 Bytes

Versions: 11

Compression:

Stored size: 561 Bytes

Contents

require 'digest/md5'

Puppet::Parser::Functions::newfunction(:fqdn_rand, :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
    srand(Digest::MD5.hexdigest([self['::fqdn'],args].join(':')).hex)
    rand(max).to_s
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
puppet-3.0.2 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.2.rc3 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.2.rc2 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.2.rc1 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.1 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.1.rc1 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.0 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.0.rc8 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.0.rc7 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.0.rc5 lib/puppet/parser/functions/fqdn_rand.rb
puppet-3.0.0.rc4 lib/puppet/parser/functions/fqdn_rand.rb