Replace psql_db => $user with $default_database.

On FreeBSD systems the $user variable is not 'postgres' so does not
match the default database correctly. These changes use the existing
default_database parameter to replace instances where $user is passed as
the database to be connected to.

These changes are in server::database, server::role and
server::grant.
This commit is contained in:
Geoff Garside 2014-03-07 15:50:03 +00:00
parent 3896baeabb
commit 688b0aa3fc
3 changed files with 6 additions and 3 deletions

View file

@ -13,6 +13,7 @@ define postgresql::server::database(
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
$version = $postgresql::server::version
$default_db = $postgresql::server::default_database
# Set the defaults for the postgresql_psql resource
Postgresql_psql {
@ -49,6 +50,7 @@ define postgresql::server::database(
postgresql_psql { "Check for existence of db '${dbname}'":
command => 'SELECT 1',
unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'",
db => $default_db,
require => Class['postgresql::server::service']
}~>
exec { $createdb_command :
@ -60,13 +62,14 @@ define postgresql::server::database(
# This will prevent users from connecting to the database unless they've been
# granted privileges.
postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public":
db => $user,
db => $default_db,
refreshonly => true,
}
Exec [ $createdb_command ]->
postgresql_psql {"UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'":
unless => "SELECT datname FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}",
db => $default_db,
}
# Build up dependencies on tablespace

View file

@ -5,7 +5,7 @@ define postgresql::server::grant (
$privilege = undef,
$object_type = 'database',
$object_name = $db,
$psql_db = $postgresql::server::user,
$psql_db = $postgresql::server::default_database,
$psql_user = $postgresql::server::user
) {
$group = $postgresql::server::group

View file

@ -3,7 +3,7 @@ define postgresql::server::role(
$password_hash = false,
$createdb = false,
$createrole = false,
$db = $postgresql::server::user,
$db = $postgresql::server::default_database,
$login = true,
$superuser = false,
$replication = false,