+Puppet::Parser::Functions.newfunction(
+ :fqdn_rotate,
+ :type => :rvalue,
+ :doc => <<-DOC
+ @summary
+ Rotates an array or string a random number of times, combining the `$fqdn` fact
+ and an optional seed for repeatable randomness.
+
+ @return
+ rotated array or string
+
+ @example Example Usage:
+ fqdn_rotate(['a', 'b', 'c', 'd'])
+ fqdn_rotate('abcd')
+ fqdn_rotate([1, 2, 3], 'custom seed')
+ DOC
+) do |args|
+
+ raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.empty?
+
+ value = args.shift
+ require 'digest/md5'
+
+ unless value.is_a?(Array) || value.is_a?(String)
+ raise(Puppet::ParseError, 'fqdn_rotate(): Requires either array or string to work with')
+ end