5 # Copyright:: 2013, 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 "accounts"
21 include_recipe "osmosis"
23 db_passwords = data_bag_item("db", "passwords")
25 package "postgresql-client"
37 remote_directory "/opt/flush" do
47 execute "/opt/flush/Makefile" do
53 subscribes :run, "remote_directory[/opt/flush]"
56 remote_directory "/usr/local/bin" do
57 source "replication-bin"
66 template "/usr/local/bin/users-agreed" do
67 source "users-agreed.erb"
73 template "/usr/local/bin/users-deleted" do
74 source "users-deleted.erb"
80 remote_directory "/store/planet/users_deleted" do
81 source "users_deleted"
90 remote_directory "/store/planet/replication" do
91 source "replication-cgi"
100 directory "/store/planet/replication/changesets" do
106 directory "/store/planet/replication/day" do
112 directory "/store/planet/replication/hour" do
118 directory "/store/planet/replication/minute" do
124 directory "/etc/replication" do
130 directory "/var/run/lock/changeset-replication/" do
136 template "/etc/replication/auth.conf" do
137 source "replication.auth.erb"
141 variables :password => db_passwords["planetdiff"]
144 template "/etc/replication/changesets.conf" do
145 source "changesets.conf.erb"
149 variables :password => db_passwords["planetdiff"]
152 template "/etc/replication/users-agreed.conf" do
153 source "users-agreed.conf.erb"
157 variables :password => db_passwords["planetdiff"]
160 directory "/var/lib/replication" do
166 directory "/var/lib/replication/hour" do
172 template "/var/lib/replication/hour/configuration.txt" do
173 source "replication.config.erb"
177 variables :base => "minute", :interval => 3600
180 link "/var/lib/replication/hour/data" do
181 to "/store/planet/replication/hour"
184 directory "/var/lib/replication/day" do
190 template "/var/lib/replication/day/configuration.txt" do
191 source "replication.config.erb"
195 variables :base => "hour", :interval => 86400
198 link "/var/lib/replication/day/data" do
199 to "/store/planet/replication/day"
202 if node[:planet][:replication] == "enabled"
203 template "/etc/cron.d/replication" do
204 source "replication.cron.erb"
210 file "/etc/cron.d/replication" do
215 # directory "/var/lib/replication/streaming" do
221 # directory "/var/log/replication" do
227 # ["streaming-replicator", "streaming-server"].each do |name|
228 # template "/etc/init.d/#{name}" do
229 # source "streaming.init.erb"
233 # variables :service => name
236 # if node[:planet][:replication] == "enabled"
238 # action [:enable, :start]
239 # supports :restart => true, :status => true
240 # subscribes :restart, "template[/etc/init.d/#{name}]"
244 # action [:disable, :stop]
245 # supports :restart => true, :status => true