]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/replication.rb
There isn't a separate rubygems package in 14.04
[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-libxml"
28
29 package "libpq-dev"
30 gem_package "pg"
31
32 remote_directory "/usr/local/bin" do
33   source "replication-bin"
34   owner "root"
35   group "root"
36   mode 0755
37   files_owner "root"
38   files_group "root"
39   files_mode 0755
40 end
41
42 remote_directory "/store/planet/replication" do
43   source "replication-cgi"
44   owner "root"
45   group "root"
46   mode 0755
47   files_owner "root"
48   files_group "root"
49   files_mode 0755
50 end
51
52 directory "/store/planet/replication/changesets" do
53   owner "planet"
54   group "planet"
55   mode 0755
56 end
57
58 directory "/store/planet/replication/day" do
59   owner "planet"
60   group "planet"
61   mode 0755
62 end
63
64 directory "/store/planet/replication/hour" do
65   owner "planet"
66   group "planet"
67   mode 0755
68 end
69
70 directory "/store/planet/replication/minute" do
71   owner "planet"
72   group "planet"
73   mode 0755
74 end
75
76 directory "/etc/replication" do
77   owner "root"
78   group "root"
79   mode 0755
80 end
81
82 template "/etc/replication/auth.conf" do
83   source "replication.auth.erb"
84   user "root"
85   group "planet"
86   mode 0640
87   variables :password => db_passwords["planetdiff"]
88 end
89
90 template "/etc/replication/changesets.conf" do
91   source "changesets.conf.erb"
92   user "root"
93   group "planet"
94   mode 0640
95   variables :password => db_passwords["planetdiff"]
96 end
97
98 template "/etc/replication/users-agreed.conf" do
99   source "users-agreed.conf.erb"
100   user "planet"
101   group "planet"
102   mode 0600
103   variables :password => db_passwords["planetdiff"]
104 end
105
106 directory "/var/lib/replication" do
107   owner "planet"
108   group "planet"
109   mode 0755
110 end
111
112 directory "/var/lib/replication/hour" do
113   owner "planet"
114   group "planet"
115   mode 0755
116 end
117
118 template "/var/lib/replication/hour/configuration.txt" do
119   source "replication.config.erb"
120   owner "planet"
121   group "planet"
122   mode 0644
123   variables :base => "minute", :interval => 3600
124 end
125
126 link "/var/lib/replication/hour/data" do
127   to "/store/planet/replication/hour"
128 end
129
130 directory "/var/lib/replication/day" do
131   owner "planet"
132   group "planet"
133   mode 0755
134 end
135
136 template "/var/lib/replication/day/configuration.txt" do
137   source "replication.config.erb"
138   owner "planet"
139   group "planet"
140   mode 0644
141   variables :base => "hour", :interval => 86400
142 end
143
144 link "/var/lib/replication/day/data" do
145   to "/store/planet/replication/day"
146 end
147
148 template "/etc/cron.d/replication" do
149   source "replication.cron.erb"
150   owner "root"
151   group "root"
152   mode 0644
153 end
154
155 directory "/var/lib/replication/streaming" do
156   owner "planet"
157   group "planet"
158   mode 0755
159 end
160
161 directory "/var/log/replication" do
162   owner "planet"
163   group "planet"
164   mode 0755
165 end
166
167 [ "streaming-replicator", "streaming-server" ].each do |name|
168   template "/etc/init.d/#{name}" do
169     source "streaming.init.erb"
170     owner "root"
171     group "root"
172     mode 0755
173     variables :service => name
174   end
175
176   service name do
177     action [ :enable, :start ]
178     supports :restart => true, :status => true
179     subscribes :restart, "template[/etc/init.d/#{name}]"
180   end
181 end