Skip to content

Conversation

ekohl
Copy link
Collaborator

@ekohl ekohl commented Mar 26, 2024

Summary

The function postgresql::password() looks at the default for encryption. If you want to use SCRAM on PostgreSQL < 14 then the default must be overridden, or specified for every use. This parameter allows it to be globally overridden.

Related Issues (if any)

Found in theforeman/foreman-installer#924 when testing out SCRAM support with PostgreSQL 13.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

The function postgresql::password() looks at the default for encryption.
If you want to use SCRAM on PostgreSQL < 14 then the default must be
overridden, or specified for every use. This parameter allows it to be
globally overridden.
@@ -25,7 +25,7 @@
$manage_selinux = pick($manage_selinux, false)
$package_ensure = 'present'
$module_workdir = pick($module_workdir,'/tmp')
$password_encryption = versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' }
$password_encryption = pick($password_encryption, versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work? pick() refrences the variable itself? And line 21-24 follow the same pattern 🤔

should it be:

Suggested change
$password_encryption = pick($password_encryption, versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' })
$password_encryption = pick($postgresql::globals::password_encryption, versioncmp($version, '14') ? { -1 => 'md5', default => 'scram-sha-256' })

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was also surprised. I think it's (ab)using the parser a bit. I wanted to remain consistent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. so it's probably coming from globals. interesting. Not sure if that works on purpose or by accident :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"yes"

@bastelfreak bastelfreak merged commit 5eb1690 into puppetlabs:main Mar 26, 2024
@ekohl ekohl deleted the globally-configurable-password-encryption branch March 26, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants