]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/replication.rb
Fix duplicate resource names
[chef.git] / cookbooks / planet / recipes / replication.rb
1 #
2 # Cookbook Name:: planet
3 # Recipe:: dump
4 #
5 # Copyright 2013, OpenStreetMap Foundation
6 #
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
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 include_recipe "osmosis"
21
22 db_passwords = data_bag_item("db", "passwords")
23
24 package "postgresql-client"
25
26 package "ruby"
27 package "ruby-dev"
28 package "ruby-libxml"
29
30 package "libpq-dev"
31 gem_package "pg"
32
33 package "make"
34 package "gcc"
35
36 remote_directory "/opt/flush" do
37   source "flush"
38   owner "root"
39   group "root"
40   mode 0o755
41   files_owner "root"
42   files_group "root"
43   files_mode 0o755
44 end
45
46 execute "/opt/flush/Makefile" do
47   action :nothing
48   command "make"
49   cwd "/opt/flush"
50   user "root"
51   group "root"
52   subscribes :run, "remote_directory[/opt/flush]"
53 end
54
55 remote_directory "/usr/local/bin" do
56   source "replication-bin"
57   owner "root"
58   group "root"
59   mode 0o755
60   files_owner "root"
61   files_group "root"
62   files_mode 0o755
63 end
64
65 template "/usr/local/bin/users-agreed" do
66   source "users-agreed.erb"
67   owner "root"
68   group "root"
69   mode 0o755
70 end
71
72 remote_directory "/store/planet/replication" do
73   source "replication-cgi"
74   owner "root"
75   group "root"
76   mode 0o755
77   files_owner "root"
78   files_group "root"
79   files_mode 0o755
80 end
81
82 directory "/store/planet/replication/changesets" do
83   owner "planet"
84   group "planet"
85   mode 0o755
86 end
87
88 directory "/store/planet/replication/day" do
89   owner "planet"
90   group "planet"
91   mode 0o755
92 end
93
94 directory "/store/planet/replication/hour" do
95   owner "planet"
96   group "planet"
97   mode 0o755
98 end
99
100 directory "/store/planet/replication/minute" do
101   owner "planet"
102   group "planet"
103   mode 0o755
104 end
105
106 directory "/etc/replication" do
107   owner "root"
108   group "root"
109   mode 0o755
110 end
111
112 template "/etc/replication/auth.conf" do
113   source "replication.auth.erb"
114   user "root"
115   group "planet"
116   mode 0o640
117   variables :password => db_passwords["planetdiff"]
118 end
119
120 template "/etc/replication/changesets.conf" do
121   source "changesets.conf.erb"
122   user "root"
123   group "planet"
124   mode 0o640
125   variables :password => db_passwords["planetdiff"]
126 end
127
128 template "/etc/replication/users-agreed.conf" do
129   source "users-agreed.conf.erb"
130   user "planet"
131   group "planet"
132   mode 0o600
133   variables :password => db_passwords["planetdiff"]
134 end
135
136 directory "/var/lib/replication" do
137   owner "planet"
138   group "planet"
139   mode 0o755
140 end
141
142 directory "/var/lib/replication/hour" do
143   owner "planet"
144   group "planet"
145   mode 0o755
146 end
147
148 template "/var/lib/replication/hour/configuration.txt" do
149   source "replication.config.erb"
150   owner "planet"
151   group "planet"
152   mode 0o644
153   variables :base => "minute", :interval => 3600
154 end
155
156 link "/var/lib/replication/hour/data" do
157   to "/store/planet/replication/hour"
158 end
159
160 directory "/var/lib/replication/day" do
161   owner "planet"
162   group "planet"
163   mode 0o755
164 end
165
166 template "/var/lib/replication/day/configuration.txt" do
167   source "replication.config.erb"
168   owner "planet"
169   group "planet"
170   mode 0o644
171   variables :base => "hour", :interval => 86400
172 end
173
174 link "/var/lib/replication/day/data" do
175   to "/store/planet/replication/day"
176 end
177
178 if node[:planet][:replication] == "enabled"
179   template "/etc/cron.d/replication" do
180     source "replication.cron.erb"
181     owner "root"
182     group "root"
183     mode 0o644
184   end
185 else
186   file "/etc/cron.d/replication" do
187     action :delete
188   end
189 end
190
191 # directory "/var/lib/replication/streaming" do
192 #   owner "planet"
193 #   group "planet"
194 #   mode 0o755
195 # end
196 #
197 # directory "/var/log/replication" do
198 #   owner "planet"
199 #   group "planet"
200 #   mode 0o755
201 # end
202 #
203 # ["streaming-replicator", "streaming-server"].each do |name|
204 #   template "/etc/init.d/#{name}" do
205 #     source "streaming.init.erb"
206 #     owner "root"
207 #     group "root"
208 #     mode 0o755
209 #     variables :service => name
210 #   end
211 #
212 #   if node[:planet][:replication] == "enabled"
213 #     service name do
214 #       action [:enable, :start]
215 #       supports :restart => true, :status => true
216 #       subscribes :restart, "template[/etc/init.d/#{name}]"
217 #     end
218 #   else
219 #     service name do
220 #       action [:disable, :stop]
221 #       supports :restart => true, :status => true
222 #     end
223 #   end
224 # end