|
81 | 81 |
|
82 | 82 | # This will prevent users from connecting to the database unless they've been
|
83 | 83 | # granted privileges.
|
84 |
| - ~> postgresql_psql { "REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public": |
| 84 | + postgresql_psql { "REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public": |
85 | 85 | refreshonly => true,
|
| 86 | + subscribe => Postgresql_psql["CREATE DATABASE \"${dbname}\""], |
86 | 87 | }
|
87 | 88 |
|
88 |
| - Postgresql_psql["CREATE DATABASE \"${dbname}\""] |
89 |
| - -> postgresql_psql { "UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'": |
90 |
| - unless => "SELECT 1 FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}", |
| 89 | + postgresql_psql { "UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'": |
| 90 | + unless => "SELECT 1 FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}", |
| 91 | + require => Postgresql_psql["CREATE DATABASE \"${dbname}\""], |
91 | 92 | }
|
92 | 93 |
|
93 | 94 | if $comment {
|
|
96 | 97 | '8.1' => 'obj_description',
|
97 | 98 | default => 'shobj_description',
|
98 | 99 | }
|
99 |
| - Postgresql_psql["CREATE DATABASE \"${dbname}\""] |
100 |
| - -> postgresql_psql { "COMMENT ON DATABASE \"${dbname}\" IS '${comment}'": |
101 |
| - unless => "SELECT 1 FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.${comment_information_function}(d.oid, 'pg_database') = '${comment}'", |
102 |
| - db => $dbname, |
| 100 | + |
| 101 | + postgresql_psql { "COMMENT ON DATABASE \"${dbname}\" IS '${comment}'": |
| 102 | + unless => "SELECT 1 FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.${comment_information_function}(d.oid, 'pg_database') = '${comment}'", |
| 103 | + db => $dbname, |
| 104 | + require => Postgresql_psql["CREATE DATABASE \"${dbname}\""], |
103 | 105 | }
|
104 | 106 | }
|
105 | 107 |
|
|
109 | 111 | require => Postgresql_psql["CREATE DATABASE \"${dbname}\""],
|
110 | 112 | }
|
111 | 113 |
|
112 |
| - if defined(Postgresql::Server::Role[$owner]) { |
113 |
| - Postgresql::Server::Role[$owner]->Postgresql_psql["ALTER DATABASE \"${dbname}\" OWNER TO \"${owner}\""] |
114 |
| - } |
| 114 | + Postgresql::Server::Role <| username == $owner |> -> Postgresql_psql["ALTER DATABASE \"${dbname}\" OWNER TO \"${owner}\""] |
115 | 115 | }
|
116 | 116 |
|
117 | 117 | if $tablespace {
|
|
120 | 120 | require => Postgresql_psql["CREATE DATABASE \"${dbname}\""],
|
121 | 121 | }
|
122 | 122 |
|
123 |
| - if defined(Postgresql::Server::Tablespace[$tablespace]) { |
124 |
| - # The tablespace must be there, before we create the database. |
125 |
| - Postgresql::Server::Tablespace[$tablespace]->Postgresql_psql["CREATE DATABASE \"${dbname}\""] |
126 |
| - } |
| 123 | + Postgresql::Server::Tablespace <| spcname == $tablespace |> -> Postgresql_psql["CREATE DATABASE \"${dbname}\""] |
127 | 124 | }
|
128 | 125 | }
|
0 commit comments