Skip to content

Instantly share code, notes, and snippets.

@richardc
Created April 25, 2012 18:48
Show Gist options
  • Save richardc/2492158 to your computer and use it in GitHub Desktop.
Save richardc/2492158 to your computer and use it in GitHub Desktop.
require 'digest/md5'
module Puppet::Parser::Functions
newfunction(:md5_splay, :type => :rvalue) do |args|
raise(Puppet::ParseError, "md5_splay(): Wrong number of arguments " +
"given (#{args.size} for 2)") if args.size != 2
value = args[0]
modulo = args[1].to_i
return Digest::MD5.hexdigest(value).hex % modulo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment