|
84 | 84 | $read_database_password = $puppetdb::params::read_database_password,
|
85 | 85 | $read_database_host = $puppetdb::params::read_database_host
|
86 | 86 | ) inherits puppetdb::params {
|
| 87 | + $port = scanf($database_port, '%i')[0] |
| 88 | + |
87 | 89 | if $manage_server {
|
88 | 90 | class { 'postgresql::globals':
|
89 | 91 | manage_package_repo => $manage_package_repo,
|
|
93 | 95 | class { 'postgresql::server':
|
94 | 96 | ip_mask_allow_all_users => '0.0.0.0/0',
|
95 | 97 | listen_addresses => $listen_addresses,
|
96 |
| - port => scanf($database_port, '%i')[0], |
| 98 | + port => $port, |
97 | 99 | }
|
98 | 100 |
|
99 | 101 | # We need to create the ssl connection for the read user, when
|
|
129 | 131 | postgresql::server::extension { 'pg_trgm':
|
130 | 132 | database => $database_name,
|
131 | 133 | require => Postgresql::Server::Db[$database_name],
|
| 134 | + port => $port, |
132 | 135 | }
|
133 | 136 | }
|
134 | 137 | }
|
|
139 | 142 | user => $database_username,
|
140 | 143 | password => $database_password,
|
141 | 144 | grant => 'all',
|
| 145 | + port => $port, |
142 | 146 | }
|
143 | 147 |
|
144 | 148 | -> postgresql_psql { 'revoke all access on public schema':
|
145 | 149 | db => $database_name,
|
| 150 | + port => $port, |
146 | 151 | command => 'REVOKE CREATE ON SCHEMA public FROM public',
|
147 | 152 | unless => "SELECT * FROM
|
148 | 153 | (SELECT has_schema_privilege('public', 'public', 'create') can_create) privs
|
|
151 | 156 |
|
152 | 157 | -> postgresql_psql { "grant all permissions to ${database_username}":
|
153 | 158 | db => $database_name,
|
| 159 | + port => $port, |
154 | 160 | command => "GRANT CREATE ON SCHEMA public TO \"${database_username}\"",
|
155 | 161 | unless => "SELECT * FROM
|
156 | 162 | (SELECT has_schema_privilege('${database_username}', 'public', 'create') can_create) privs
|
|
162 | 168 | database_name => $database_name,
|
163 | 169 | password_hash => postgresql::postgresql_password($read_database_username, $read_database_password),
|
164 | 170 | database_owner => $database_username,
|
| 171 | + database_port => $port, |
165 | 172 | }
|
166 | 173 |
|
167 | 174 | -> postgresql_psql { "grant ${read_database_username} role to ${database_username}":
|
168 | 175 | db => $database_name,
|
| 176 | + port => $port, |
169 | 177 | command => "GRANT \"${read_database_username}\" TO \"${database_username}\"",
|
170 | 178 | unless => "SELECT oid, rolname FROM pg_roles WHERE
|
171 | 179 | pg_has_role( '${database_username}', oid, 'member') and rolname = '${read_database_username}'";
|
|
0 commit comments