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 "planetdump" do
45 cluster node[:db][:cluster]
46 password passwords["planetdump"]
49 postgresql_user "planetdiff" do
50 cluster node[:db][:cluster]
51 password passwords["planetdiff"]
55 postgresql_user "backup" do
56 cluster node[:db][:cluster]
57 password passwords["backup"]
60 postgresql_user "munin" do
61 cluster node[:db][:cluster]
62 password passwords["munin"]
65 postgresql_user "replication" do
66 cluster node[:db][:cluster]
67 password passwords["replication"]
71 postgresql_database "openstreetmap" do
72 cluster node[:db][:cluster]
76 postgresql_extension "btree_gist" do
77 cluster node[:db][:cluster]
78 database "openstreetmap"
79 only_if { node[:postgresql][:clusters][node[:db][:cluster]] && node[:postgresql][:clusters][node[:db][:cluster]][:version] >= 9.0 }
82 cookbook_file "/usr/local/share/monthly-reindex.sql" do
88 systemd_service "monthly-reindex" do
89 description "Monthly database reindex"
90 exec_start "/usr/bin/psql -f /usr/local/share/monthly-reindex.sql openstreetmap"
93 restrict_address_families "AF_UNIX"
96 systemd_timer "monthly-reindex" do
97 description "Monthly database reindex"
98 on_calendar "Sun *-*-1..7 02:00"
101 service "monthly-reindex.timer" do
102 action [:enable, :start]
105 cookbook_file "/usr/local/share/yearly-reindex.sql" do
111 systemd_service "yearly-reindex" do
112 description "Yearly database reindex"
113 exec_start "/usr/bin/psql -f /usr/local/share/yearly-reindex.sql openstreetmap"
116 restrict_address_families "AF_UNIX"
119 systemd_timer "yearly-reindex" do
120 description "Yearly database reindex"
121 on_calendar "Fri *-1-8..14 02:00"
124 service "yearly-reindex.timer" do
125 action [:enable, :start]