Manage the replication directory
[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 "ruby-libxml"
26
27 gem_package "pg"
28
29 remote_directory "/usr/local/bin" do
30   source "replication-bin"
31   owner "root"
32   group "root"
33   mode 0755
34   files_owner "root"
35   files_group "root"
36   files_mode 0755
37 end
38
39 remote_directory "/store/planet/replication" do
40   source "replication-cgi"
41   owner "root"
42   group "root"
43   mode 0755
44   files_owner "root"
45   files_group "root"
46   files_mode 0755
47 end
48
49 directory "/store/planet/replication/changesets" do
50   owner "planet"
51   group "planet"
52   mode 0755
53 end
54
55 directory "/store/planet/replication/day" do
56   owner "planet"
57   group "planet"
58   mode 0755
59 end
60
61 directory "/store/planet/replication/hour" do
62   owner "planet"
63   group "planet"
64   mode 0755
65 end
66
67 directory "/store/planet/replication/minute" do
68   owner "planet"
69   group "planet"
70   mode 0755
71 end
72
73 directory "/etc/replication" do
74   owner "root"
75   group "root"
76   mode 0755
77 end
78
79 template "/etc/replication/auth.conf" do
80   source "replication.auth.erb"
81   user "root"
82   group "planet"
83   mode 0640
84   variables :password => db_passwords["planetdiff"]
85 end
86
87 template "/etc/replication/changesets.conf" do
88   source "changesets.conf.erb"
89   user "root"
90   group "planet"
91   mode 0640
92   variables :password => db_passwords["planetdiff"]
93 end
94
95 directory "/var/lib/replication" do
96   owner "planet"
97   group "planet"
98   mode 0755
99 end
100
101 directory "/var/lib/replication/hour" do
102   owner "planet"
103   group "planet"
104   mode 0755
105 end
106
107 template "/var/lib/replication/hour/configuration.txt" do
108   source "replication.config.erb"
109   owner "planet"
110   group "planet"
111   mode 0644
112   variables :base => "minute", :interval => 3600
113 end
114
115 link "/var/lib/replication/hour/data" do
116   to "/store/planet/replication/hour"
117 end
118
119 directory "/var/lib/replication/day" do
120   owner "planet"
121   group "planet"
122   mode 0755
123 end
124
125 template "/var/lib/replication/day/configuration.txt" do
126   source "replication.config.erb"
127   owner "planet"
128   group "planet"
129   mode 0644
130   variables :base => "hour", :interval => 86400
131 end
132
133 link "/var/lib/replication/day/data" do
134   to "/store/planet/replication/day"
135 end
136
137 template "/etc/cron.d/replication" do
138   source "replication.cron.erb"
139   owner "root"
140   group "root"
141   mode 0644
142 end