- seed = Digest::MD5.hexdigest([lookupvar('::fqdn'),args].join(':')).hex
- # deterministic_rand() was added in Puppet 3.2.0; reimplement if necessary
- if Puppet::Util.respond_to?(:deterministic_rand)
- offset = Puppet::Util.deterministic_rand(seed, elements).to_i
- else
- if defined?(Random) == 'constant' && Random.class == Class
- offset = Random.new(seed).rand(elements)
- else
- old_seed = srand(seed)
- offset = rand(elements)
- srand(old_seed)
- end
- end
- offset.times {
- result.push result.shift
- }