5 # Copyright:: 2011, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 include_recipe "db::base"
22 passwords = data_bag_item("db", "passwords")
24 postgresql_user "tomh" do
25 cluster node[:db][:cluster]
29 postgresql_user "matt" do
30 cluster node[:db][:cluster]
34 postgresql_user "openstreetmap" do
35 cluster node[:db][:cluster]
36 password passwords["openstreetmap"]
39 postgresql_user "rails" do
40 cluster node[:db][:cluster]
41 password passwords["rails"]
44 postgresql_user "cgimap" do
45 cluster node[:db][:cluster]
46 password passwords["cgimap"]
49 postgresql_user "planetdump" do
50 cluster node[:db][:cluster]
51 password passwords["planetdump"]
54 postgresql_user "planetdiff" do
55 cluster node[:db][:cluster]
56 password passwords["planetdiff"]
60 postgresql_user "backup" do
61 cluster node[:db][:cluster]
62 password passwords["backup"]
65 postgresql_user "munin" do
66 cluster node[:db][:cluster]
67 password passwords["munin"]
70 postgresql_user "replication" do
71 cluster node[:db][:cluster]
72 password passwords["replication"]
76 postgresql_database "openstreetmap" do
77 cluster node[:db][:cluster]
81 postgresql_extension "btree_gist" do
82 cluster node[:db][:cluster]
83 database "openstreetmap"
84 only_if { node[:postgresql][:clusters][node[:db][:cluster]] && node[:postgresql][:clusters][node[:db][:cluster]][:version] >= 9.0 }
88 active_storage_attachments
90 active_storage_variant_records
98 postgresql_table table do
99 cluster node[:db][:cluster]
100 database "openstreetmap"
101 owner "openstreetmap"
102 permissions "openstreetmap" => [:all],
103 "rails" => [:select, :insert, :update, :delete],
104 "backup" => [:select]
110 changesets_subscribers
113 diary_entry_subscriptions
127 postgresql_table table do
128 cluster node[:db][:cluster]
129 database "openstreetmap"
130 owner "openstreetmap"
131 permissions "openstreetmap" => [:all],
132 "rails" => [:select, :insert, :update, :delete],
133 "planetdump" => [:select],
134 "planetdiff" => [:select],
135 "backup" => [:select]
147 postgresql_table table do
148 cluster node[:db][:cluster]
149 database "openstreetmap"
150 owner "openstreetmap"
151 permissions "openstreetmap" => [:all],
152 "rails" => [:select, :insert, :update, :delete],
153 "cgimap" => [:select],
154 "planetdump" => [:select],
155 "planetdiff" => [:select],
156 "backup" => [:select]
160 %w[changesets].each do |table|
161 postgresql_table table do
162 cluster node[:db][:cluster]
163 database "openstreetmap"
164 owner "openstreetmap"
165 permissions "openstreetmap" => [:all],
166 "rails" => [:select, :insert, :update, :delete],
167 "cgimap" => [:select, :update],
168 "planetdump" => [:select],
169 "planetdiff" => [:select],
170 "backup" => [:select]
179 postgresql_table table do
180 cluster node[:db][:cluster]
181 database "openstreetmap"
182 owner "openstreetmap"
183 permissions "openstreetmap" => [:all],
184 "rails" => [:select, :insert, :update, :delete],
185 "cgimap" => [:select, :insert, :update],
186 "planetdump" => [:select],
187 "planetdiff" => [:select],
188 "backup" => [:select]
194 current_relation_members
195 current_relation_tags
199 postgresql_table table do
200 cluster node[:db][:cluster]
201 database "openstreetmap"
202 owner "openstreetmap"
203 permissions "openstreetmap" => [:all],
204 "rails" => [:select, :insert, :update, :delete],
205 "cgimap" => [:select, :insert, :delete],
206 "planetdump" => [:select],
207 "planetdiff" => [:select],
208 "backup" => [:select]
222 postgresql_table table do
223 cluster node[:db][:cluster]
224 database "openstreetmap"
225 owner "openstreetmap"
226 permissions "openstreetmap" => [:all],
227 "rails" => [:select, :insert, :update, :delete],
228 "cgimap" => [:select, :insert],
229 "planetdump" => [:select],
230 "planetdiff" => [:select],
231 "backup" => [:select]
241 postgresql_table table do
242 cluster node[:db][:cluster]
243 database "openstreetmap"
244 owner "openstreetmap"
245 permissions "openstreetmap" => [:all],
246 "rails" => [:select, :insert, :update, :delete],
247 "cgimap" => [:select],
248 "backup" => [:select]
255 postgresql_table table do
256 cluster node[:db][:cluster]
257 database "openstreetmap"
258 owner "openstreetmap"
259 permissions "openstreetmap" => [:all],
260 "rails" => [:select, :insert, :update, :delete],
261 "cgimap" => [:select, :insert],
262 "backup" => [:select]
268 active_storage_attachments_id_seq
269 active_storage_blobs_id_seq
270 active_storage_variant_records_id_seq
271 changeset_comments_id_seq
273 client_applications_id_seq
275 diary_comments_id_seq
280 issue_comments_id_seq
285 oauth_access_grants_id_seq
286 oauth_access_tokens_id_seq
287 oauth_applications_id_seq
288 oauth_openid_requests_id_seq
297 postgresql_sequence sequence do
298 cluster node[:db][:cluster]
299 database "openstreetmap"
300 owner "openstreetmap"
301 permissions "openstreetmap" => [:all],
303 "backup" => [:select]
309 current_relations_id_seq
313 postgresql_sequence sequence do
314 cluster node[:db][:cluster]
315 database "openstreetmap"
316 owner "openstreetmap"
317 permissions "openstreetmap" => [:all],
319 "cgimap" => [:update],
320 "backup" => [:select]
324 cookbook_file "/usr/local/share/monthly-reindex.sql" do
330 systemd_service "monthly-reindex" do
331 description "Monthly database reindex"
332 exec_start "/usr/bin/psql -f /usr/local/share/monthly-reindex.sql openstreetmap"
335 restrict_address_families "AF_UNIX"
338 systemd_timer "monthly-reindex" do
339 description "Monthly database reindex"
340 on_calendar "Sun *-*-1..7 02:00"
343 service "monthly-reindex.timer" do
344 action [:enable, :start]
347 cookbook_file "/usr/local/share/yearly-reindex.sql" do
353 systemd_service "yearly-reindex" do
354 description "Yearly database reindex"
355 exec_start "/usr/bin/psql -f /usr/local/share/yearly-reindex.sql openstreetmap"
358 restrict_address_families "AF_UNIX"
361 systemd_timer "yearly-reindex" do
362 description "Yearly database reindex"
363 on_calendar "Fri *-1-8..14 02:00"
366 service "yearly-reindex.timer" do
367 action [:enable, :start]