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