14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'manifests/server/db.pp', line 14
define postgresql::server::db (
String[1] $user,
Optional[Variant[String, Sensitive[String]]] $password = undef,
Optional[String[1]] $comment = undef,
String[1] $dbname = $title,
Optional[String[1]] $encoding = $postgresql::server::encoding,
Optional[String[1]] $locale = $postgresql::server::locale,
Variant[String[1], Array[String[1]]] $grant = 'ALL',
Optional[String[1]] $tablespace = undef,
String[1] $template = 'template0',
Boolean $istemplate = false,
Optional[String[1]] $owner = undef
) {
if ! defined(Postgresql::Server::Database[$dbname]) {
postgresql::server::database { $dbname:
comment => $comment,
encoding => $encoding,
tablespace => $tablespace,
template => $template,
locale => $locale,
istemplate => $istemplate,
owner => $owner,
}
}
if ! defined(Postgresql::Server::Role[$user]) {
postgresql::server::role { $user:
password_hash => $password,
before => Postgresql::Server::Database[$dbname],
}
}
if ! defined(Postgresql::Server::Database_grant["GRANT ${user} - ${grant} - ${dbname}"]) {
postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${dbname}":
privilege => $grant,
db => $dbname,
role => $user,
} -> Postgresql_conn_validator<| db_name == $dbname |>
}
if ($tablespace != undef and defined(Postgresql::Server::Tablespace[$tablespace])) {
Postgresql::Server::Tablespace[$tablespace] -> Postgresql::Server::Database[$name]
}
}
|