Hi,
I'm currently trying to write a simple function to generate a random
password. I have looked at the fqdn_rand.rb script to get things going
but unfortunately my ruby skills are very bad.
I found the following code snippet that does what I need:
begin
def random_password(size = 8)
chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0)
(1..size).collect{|a| chars[rand(chars.size)] }.join
end
puts random_password.inspect
end
I just can't get this to work in my custom function:
cat ../lib/puppet/parser/functions/rand_pw.rb
Puppet::Parser::Functions::newfunction(:rand_pw, :type
=> :rvalue, :doc => "Returns a random string.") do |args|
chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0)
(1..args[0]).collect{|a| chars[rand(chars.args[0])] }.join
end
and this is the function call in the manifest:
$username2pass = rand_pw(10)
The error I get is:
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: bad value for range at /etc/puppet/modules/production/users/
manifests/params.pp:11 on node
Regards,
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.