diff --git a/manifests/server/database.pp b/manifests/server/database.pp index adeabde..7d298c9 100644 --- a/manifests/server/database.pp +++ b/manifests/server/database.pp @@ -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 diff --git a/manifests/server/grant.pp b/manifests/server/grant.pp index d24130c..0efd00e 100644 --- a/manifests/server/grant.pp +++ b/manifests/server/grant.pp @@ -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 diff --git a/manifests/server/role.pp b/manifests/server/role.pp index 971191f..631f5bb 100644 --- a/manifests/server/role.pp +++ b/manifests/server/role.pp @@ -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,