]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/dump.rb
wiki: Fix baseUri for wikibase
[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 "git"
21 include_recipe "planet::user"
22
23 db_passwords = data_bag_item("db", "passwords")
24
25 package %w[
26   gcc
27   g++
28   make
29   autoconf
30   automake
31   pkg-config
32   libxml2-dev
33   libboost-dev
34   libboost-program-options-dev
35   libboost-date-time-dev
36   libboost-filesystem-dev
37   libboost-thread-dev
38   libboost-iostreams-dev
39   libosmpbf-dev
40   libprotobuf-dev
41   osmpbf-bin
42   pbzip2
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 template "/usr/local/bin/planetdump" do
99   source "planetdump.erb"
100   owner "root"
101   group "root"
102   mode "755"
103   variables :password => db_passwords["planetdump"]
104 end
105
106 systemd_service "planetdump@" do
107   action :delete
108 end
109
110 systemd_service "planetdump" do
111   description "Planet dump"
112   user "planet"
113   exec_start "/usr/local/bin/planetdump"
114   memory_max "64G"
115   sandbox :enable_network => true
116   protect_home "tmpfs"
117   bind_paths "/home/planet"
118   read_write_paths [
119     "/store/planetdump",
120     "/store/planet/pbf",
121     "/store/planet/planet",
122     "/var/log/exim4",
123     "/var/spool/exim4"
124   ]
125 end
126
127 systemd_timer "planetdump" do
128   description "Planet dump"
129   on_calendar "Mon 02:00 #{node[:timezone]}"
130 end
131
132 service "planetdump.timer" do
133   action [:enable, :start]
134 end
135
136 service "planetdump-trigger" do
137   action [:disable, :stop]
138 end
139
140 systemd_service "planetdump-trigger" do
141   action :delete
142 end
143
144 file "/usr/local/bin/planetdump-trigger" do
145   action :delete
146 end