2013-08-27 22:43:47 +02:00
|
|
|
# Define for conveniently creating a role, database and assigning the correct
|
|
|
|
# permissions. See README.md for more details.
|
|
|
|
define postgresql::server::db (
|
|
|
|
$user,
|
|
|
|
$password,
|
|
|
|
$encoding = $postgresql::server::encoding,
|
|
|
|
$locale = $postgresql::server::locale,
|
|
|
|
$grant = 'ALL',
|
|
|
|
$tablespace = undef,
|
|
|
|
$istemplate = false
|
|
|
|
) {
|
|
|
|
postgresql::server::database { $name:
|
|
|
|
encoding => $encoding,
|
|
|
|
tablespace => $tablespace,
|
|
|
|
locale => $locale,
|
|
|
|
istemplate => $istemplate,
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! defined(Postgresql::Server::Role[$user]) {
|
|
|
|
postgresql::server::role { $user:
|
2013-09-03 20:46:07 +02:00
|
|
|
password_hash => $password,
|
2013-08-27 22:43:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${name}":
|
2013-09-03 20:46:07 +02:00
|
|
|
privilege => $grant,
|
|
|
|
db => $name,
|
|
|
|
role => $user,
|
2013-08-27 22:43:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if($tablespace != undef and defined(Postgresql::Server::Tablespace[$tablespace])) {
|
|
|
|
Postgresql::Server::Tablespace[$tablespace]->Postgresql::Server::Database[$name]
|
|
|
|
}
|
|
|
|
}
|