Puppet Function: postgresql::postgresql_password
- Defined in:
-
lib/puppet/functions/postgresql/postgresql_password.rb
- Function type:
- Ruby 4.x API
Summary
This function returns the postgresql password hash from the clear text username / password
Overview
postgresql::postgresql_password(Variant[String[1], Integer] $username, Variant[String[1], Sensitive[String[1]], Integer] $password, Optional[Boolean] $sensitive) ⇒ Variant[String, Sensitive[String]]
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/puppet/functions/postgresql/postgresql_password.rb', line 4
Puppet::Functions.create_function(:'postgresql::postgresql_password') do
dispatch :default_impl do
required_param 'Variant[String[1], Integer]', :username
required_param 'Variant[String[1], Sensitive[String[1]], Integer]', :password
optional_param 'Boolean', :sensitive
return_type 'Variant[String, Sensitive[String]]'
end
def default_impl(username, password, sensitive = false)
password = password.unwrap if password.respond_to?(:unwrap)
result_string = 'md5' + Digest::MD5.hexdigest(password.to_s + username.to_s)
if sensitive
Puppet::Pops::Types::PSensitiveType::Sensitive.new(result_string)
else
result_string
end
end
end
|