Sha256: 34ea72e1145162e5b76a04d4106159e206bc47944e4e0990cf86bcedf35a7759

Contents?: true

Size: 564 Bytes

Versions: 26

Compression:

Stored size: 564 Bytes

Contents

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|
    require 'digest/md5'
    max = args.shift
    srand(Digest::MD5.hexdigest([lookupvar('::fqdn'),args].join(':')).hex)
    rand(max).to_s
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.18 lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.17 lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.16 lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.14 lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.13 lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.12 lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.11 lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/functions/fqdn_rand.rb
puppet-2.7.9 lib/puppet/parser/functions/fqdn_rand.rb