Puppet Function: simplib::passgen::gen_password_and_salt
- Defined in:
- lib/puppet/functions/simplib/passgen/gen_password_and_salt.rb
- Function type:
- Ruby 4.x API
Overview
Generates a password and salt
-
Password length, complexity and complex-only settings are specified by the caller.
-
Salt length, complexity and complex-only settings are hard-coded to values appropriate for a salt.
-
Terminates catalog compilation if the password and salt cannot be created in the allotted time.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/puppet/functions/simplib/passgen/gen_password_and_salt.rb', line 11 Puppet::Functions.create_function(:'simplib::passgen::gen_password_and_salt') do # @param length Length of the new password. # # @param complexity Specifies the types of characters to be used in the # password # * `0` => Use only Alphanumeric characters (safest) # * `1` => Use Alphanumeric characters and reasonably safe symbols # * `2` => Use any printable ASCII characters # # @param complex_only Use only the characters explicitly added by the # complexity rules # # @param timeout_seconds Maximum time allotted to generate the password or # the salt; a value of 0 disables the timeout # # @return [Array] Generated <password,salt> pair # # @raise [Timeout::Error] if password cannot be created within allotted time # dispatch :gen_password_and_salt do required_param 'Integer[8]', :length required_param 'Integer[0,2]', :complexity required_param 'Boolean', :complex_only required_param 'Variant[Integer[0],Float[0]]', :timeout_seconds end def gen_password_and_salt(length, complexity, complex_only, timeout_seconds) password = call_function('simplib::gen_random_password', length, complexity, complex_only, timeout_seconds) salt = call_function('simplib::passgen::gen_salt', timeout_seconds) [password, salt] end end |