]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/replication.rb
Install libpq-dev for the pg gem
[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 directory "/var/lib/replication" do
98   owner "planet"
99   group "planet"
100   mode 0755
101 end
102
103 directory "/var/lib/replication/hour" do
104   owner "planet"
105   group "planet"
106   mode 0755
107 end
108
109 template "/var/lib/replication/hour/configuration.txt" do
110   source "replication.config.erb"
111   owner "planet"
112   group "planet"
113   mode 0644
114   variables :base => "minute", :interval => 3600
115 end
116
117 link "/var/lib/replication/hour/data" do
118   to "/store/planet/replication/hour"
119 end
120
121 directory "/var/lib/replication/day" do
122   owner "planet"
123   group "planet"
124   mode 0755
125 end
126
127 template "/var/lib/replication/day/configuration.txt" do
128   source "replication.config.erb"
129   owner "planet"
130   group "planet"
131   mode 0644
132   variables :base => "hour", :interval => 86400
133 end
134
135 link "/var/lib/replication/day/data" do
136   to "/store/planet/replication/day"
137 end
138
139 template "/etc/cron.d/replication" do
140   source "replication.cron.erb"
141   owner "root"
142   group "root"
143   mode 0644
144 end
145
146 directory "/var/lib/replication/streaming" do
147   owner "planet"
148   group "planet"
149   mode 0755
150 end
151
152 directory "/var/log/replication" do
153   owner "planet"
154   group "planet"
155   mode 0755
156 end
157
158 [ "streaming-replicator", "streaming-server" ].each do |name|
159   template "/etc/init.d/#{name}" do
160     source "streaming.init.erb"
161     owner "root"
162     group "root"
163     mode 0755
164     variables :service => name
165   end
166
167   service name do
168     action [ :enable, :start ]
169     supports :restart => true, :status => true
170     subscribes :restart, "template[/etc/init.d/#{name}]"
171   end
172 end