Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ADMIN OPTION when granting a role #1618

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions manifests/server/grant_role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
# @param port Port to use when connecting.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param instance The name of the Postgresql database instance.
# @param with_admin_option Specifies if the role should be granted with admin option.
define postgresql::server::grant_role (
String[1] $group,
String[1] $role = $name,
Enum['present', 'absent'] $ensure = 'present',
String[1] $instance = 'main',
String[1] $psql_db = $postgresql::server::default_database,
String[1] $psql_user = $postgresql::server::user,
Stdlib::Port $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
String[1] $role = $name,
Enum['present', 'absent'] $ensure = 'present',
String[1] $instance = 'main',
String[1] $psql_db = $postgresql::server::default_database,
String[1] $psql_user = $postgresql::server::user,
Stdlib::Port $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Boolean $with_admin_option = false,
) {
case $ensure {
'present': {
$command = "GRANT \"${group}\" TO \"${role}\""
$with_admin_option_sql = $with_admin_option ? { true => 'WITH ADMIN OPTION', default => '' }
$command = "GRANT \"${group}\" TO \"${role}\" ${with_admin_option_sql}"
$unless_comp = '='
}
'absent': {
Expand Down
Loading