diff --git a/REFERENCE.md b/REFERENCE.md index f4e078778b..a0e6a924df 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -4429,6 +4429,8 @@ Data type: `Optional[Optional[Postgresql::Pg_password_encryption]]` Set type for password hash +Default value comes from `postgresql::params::password_encryption` and changes based on the `postgresql::globals::version`. + ##### `salt` Data type: `Optional[Optional[Variant[String[1], Integer]]]` diff --git a/lib/puppet/functions/postgresql/postgresql_password.rb b/lib/puppet/functions/postgresql/postgresql_password.rb index 68be8b7374..ef899254da 100644 --- a/lib/puppet/functions/postgresql/postgresql_password.rb +++ b/lib/puppet/functions/postgresql/postgresql_password.rb @@ -13,6 +13,8 @@ # If the Postgresql-Passwordhash should be of Datatype Sensitive[String] # @param hash # Set type for password hash + # + # Default value comes from `postgresql::params::password_encryption` and changes based on the `postgresql::globals::version`. # @param salt # Use a specific salt value for scram-sha-256, default is username # @@ -27,7 +29,8 @@ return_type 'Variant[String, Sensitive[String]]' end - def default_impl(username, password, sensitive = false, hash = 'md5', salt = nil) + def default_impl(username, password, sensitive = false, hash = nil, salt = nil) + hash = call_function(:'postgresql::default', 'password_encryption') if hash.nil? password = password.unwrap if password.respond_to?(:unwrap) if password.is_a?(String) && password.match?(%r{^(md5[0-9a-f]{32}$|SCRAM-SHA-256\$)}) return Puppet::Pops::Types::PSensitiveType::Sensitive.new(password) if sensitive diff --git a/spec/functions/postgresql_password_spec.rb b/spec/functions/postgresql_password_spec.rb index 0cd765d6b8..1c75c9b6f8 100644 --- a/spec/functions/postgresql_password_spec.rb +++ b/spec/functions/postgresql_password_spec.rb @@ -3,5 +3,7 @@ require 'spec_helper' describe 'postgresql_password' do + include_examples 'Ubuntu 18.04' + it_behaves_like 'postgresql_password function' end diff --git a/spec/functions/postgresql_postgresql_password_spec.rb b/spec/functions/postgresql_postgresql_password_spec.rb index d70feaf15b..d66e5afea9 100644 --- a/spec/functions/postgresql_postgresql_password_spec.rb +++ b/spec/functions/postgresql_postgresql_password_spec.rb @@ -3,5 +3,7 @@ require 'spec_helper' describe 'postgresql::postgresql_password' do + include_examples 'Ubuntu 18.04' + it_behaves_like 'postgresql_password function' end