]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/dump.rb
Copy tile logs to S3
[chef.git] / cookbooks / planet / recipes / dump.rb
1 #
2 # Cookbook:: 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 #     https://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 "accounts"
21 include_recipe "git"
22
23 package %w[
24   gcc
25   g++
26   make
27   autoconf
28   automake
29   pkg-config
30   libxml2-dev
31   libboost-dev
32   libboost-program-options-dev
33   libboost-date-time-dev
34   libboost-filesystem-dev
35   libboost-thread-dev
36   libboost-iostreams-dev
37   libosmpbf-dev
38   libprotobuf-dev
39   osmpbf-bin
40   pbzip2
41   php-cli
42   php-curl
43   mktorrent
44   xmlstarlet
45   libxml2-utils
46   inotify-tools
47 ]
48
49 directory "/opt/planet-dump-ng" do
50   owner "root"
51   group "root"
52   mode "755"
53 end
54
55 git "/opt/planet-dump-ng" do
56   action :sync
57   repository "https://github.com/zerebubuth/planet-dump-ng.git"
58   revision "v1.2.7"
59   depth 1
60   user "root"
61   group "root"
62 end
63
64 execute "/opt/planet-dump-ng/autogen.sh" do
65   action :nothing
66   command "./autogen.sh"
67   cwd "/opt/planet-dump-ng"
68   user "root"
69   group "root"
70   subscribes :run, "git[/opt/planet-dump-ng]"
71 end
72
73 execute "/opt/planet-dump-ng/configure" do
74   action :nothing
75   command "./configure"
76   cwd "/opt/planet-dump-ng"
77   user "root"
78   group "root"
79   subscribes :run, "execute[/opt/planet-dump-ng/autogen.sh]"
80 end
81
82 execute "/opt/planet-dump-ng/Makefile" do
83   action :nothing
84   command "make"
85   cwd "/opt/planet-dump-ng"
86   user "root"
87   group "root"
88   subscribes :run, "execute[/opt/planet-dump-ng/configure]"
89 end
90
91 directory "/store/planetdump" do
92   owner "planet"
93   group "planet"
94   mode "755"
95   recursive true
96 end
97
98 %w[planetdump planetdump-trigger planet-mirror-redirect-update].each do |program|
99   template "/usr/local/bin/#{program}" do
100     source "#{program}.erb"
101     owner "root"
102     group "root"
103     mode "755"
104   end
105 end
106
107 systemd_service "planetdump@" do
108   description "Planet dump for %i"
109   user "planet"
110   exec_start "/usr/local/bin/planetdump %i"
111   memory_max "64G"
112   sandbox true
113   read_write_paths [
114     "/store/planetdump",
115     "/store/planet/pbf",
116     "/store/planet/planet",
117     "/var/log/exim4",
118     "/var/spool/exim4"
119   ]
120 end
121
122 systemd_service "planetdump-trigger" do
123   description "Planet dump trigger"
124   user "root"
125   exec_start "/usr/local/bin/planetdump-trigger"
126   sandbox true
127   restrict_address_families "AF_UNIX"
128 end
129
130 service "planetdump-trigger" do
131   action [:enable, :start]
132   subscribes :restart, "template[/usr/local/bin/planetdump-trigger]"
133 end
134
135 systemd_service "planet-dump-mirror" do
136   description "Update planet dump mirrors"
137   exec_start "/usr/local/bin/planet-mirror-redirect-update"
138   user "planet"
139   sandbox :enable_network => true
140   memory_deny_write_execute false
141   read_write_paths "/store/planet/.htaccess"
142 end
143
144 systemd_timer "planet-dump-mirror" do
145   description "Update planet dump mirrors"
146   on_boot_sec "10min"
147   on_unit_inactive_sec "10min"
148 end
149
150 service "planet-dump-mirror.timer" do
151   action [:enable, :start]
152 end