Puppet Function: generate_password
- Defined in:
-
lib/puppet/parser/functions/generate_password.rb
- Function type:
- Ruby 3.x API
Overview
generate_password() ⇒ Any
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/puppet/parser/functions/generate_password.rb', line 6
newfunction(:generate_password, :type => :rvalue) do |args|
Puppet::Parser::Functions.autoloader.loadall
length = args[0].to_i
seed = args[1]
charnumber = 0
password = ""
while charnumber < length do
randchar = function_fqdn_rand( [ 26, seed + charnumber.to_s ] )
if function_fqdn_rand( [ 2, seed + (charnumber + length).to_s ] ).to_i == 1.to_i
starting = 65
else
starting = 97
end
randchar = starting + randchar.to_i
char = randchar.chr
password = password + char
charnumber = charnumber + 1
end
password
end
|