[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. 90c4a6028cf6ebd530af736ce08f1b413698b162

Micah Anderson micah at riseup.net
Sat May 31 17:15:34 UTC 2008


The following commit has been merged in the master branch:
commit 9f0f325ff0df1b10b81564c54cd653b83df7d0d7
Author: James Turnbull <james at lovedthanlost.net>
Date:   Sat May 24 10:18:28 2008 +1000

    Put function in ticket #311 in correct location

diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index 9399127..8decb82 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -188,6 +188,22 @@ module Functions
         result
     end
 
+    newfunction(:fqdn_rand, :type => :rvalue, :doc => "Generates random 
+    numbers based on the node's fqdn. The first argument sets the range.
+    The second argument specifies a number to add to the seed and is
+    optional.") do |args|
+	require 'md5'
+	max = args[0] 
+	if args[1] then
+	     seed = args[1]
+	else
+	     seed = 1
+	end
+	fqdn_seed = MD5.new(lookupvar('fqdn')).to_s.hex
+	srand(seed+fqdn_seed)
+	rand(max).to_s
+    end 
+
     newfunction(:fail, :doc => "Fail with a parse error.") do |vals|
         vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array
         raise Puppet::ParseError, vals.to_s

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list