Puppet Function: :'wmflib::autogen_password'

Defined in:
modules/wmflib/lib/puppet/functions/wmflib/autogen_password.rb
Function type:
Ruby 4.x API

Overview

:'wmflib::autogen_password'(String $username, String $seed)Any

Parameters:

  • username (String)

    the username to generate the password for

  • seed (String)

    the seed to use to generate the password.

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
# File 'modules/wmflib/lib/puppet/functions/wmflib/autogen_password.rb', line 2

Puppet::Functions.create_function(:'wmflib::autogen_password') do
  # returns a 20-character-limited string to be used as a password
  # @param username the username to generate the password for
  # @param seed the seed to use to generate the password.
  dispatch :autogen_password do
    param 'String', :username
    param 'String', :seed
  end
  def autogen_password(username, seed)
    Digest::SHA256.base64digest("#{seed}|||#{username}")[0..20]
  end
end