]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/replication.rb
2d9dc4f4b631839f34ca9d485ba27b5d98c87dd8
[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 template "/usr/local/bin/replicate-changesets" do
30   source "changesets.bin.erb"
31   owner "root"
32   group "root"
33   mode 0755
34 end
35
36 directory "/etc/replication" do
37   owner "root"
38   group "root"
39   mode 0755
40 end
41
42 template "/etc/replication/auth.conf" do
43   source "replication.auth.erb"
44   user "root"
45   group "planet"
46   mode 0640
47   variables :password => db_passwords["planetdiff"]
48 end
49
50 template "/etc/replication/changesets.conf" do
51   source "changesets.conf.erb"
52   user "root"
53   group "planet"
54   mode 0640
55   variables :password => db_passwords["planetdiff"]
56 end
57
58 directory "/var/lib/replication" do
59   owner "planet"
60   group "planet"
61   mode 0755
62 end
63
64 directory "/var/lib/replication/hour" do
65   owner "planet"
66   group "planet"
67   mode 0755
68 end
69
70 template "/var/lib/replication/hour/configuration.txt" do
71   source "replication.config.erb"
72   owner "planet"
73   group "planet"
74   mode 0644
75   variables :base => "minute", :interval => 3600
76 end
77
78 link "/var/lib/replication/hour/data" do
79   to "/store/planet/replication/hour"
80 end
81
82 directory "/var/lib/replication/day" do
83   owner "planet"
84   group "planet"
85   mode 0755
86 end
87
88 template "/var/lib/replication/hour/configuration.txt" do
89   source "replication.config.erb"
90   owner "planet"
91   group "planet"
92   mode 0644
93   variables :base => "hour", :interval => 86400
94 end
95
96 link "/var/lib/replication/day/data" do
97   to "/store/planet/replication/day"
98 end
99
100 template "/etc/cron.d/replication" do
101   source "replication.cron.erb"
102   owner "root"
103   group "root"
104   mode 0644
105 end