]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/dump.rb
Use strings for file modes
[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 node.default[:incron][:planetdump] = {
21   :user => "root",
22   :path => "/store/backup",
23   :events => %w[IN_CREATE IN_MOVED_TO],
24   :command => "/usr/bin/systemctl start planetdump@$#"
25 }
26
27 include_recipe "git"
28 include_recipe "incron"
29
30 package %w[
31   gcc
32   g++
33   make
34   autoconf
35   automake
36   pkg-config
37   libxml2-dev
38   libboost-dev
39   libboost-program-options-dev
40   libboost-date-time-dev
41   libboost-filesystem-dev
42   libboost-thread-dev
43   libboost-iostreams-dev
44   libosmpbf-dev
45   libprotobuf-dev
46   osmpbf-bin
47   pbzip2
48   php-cli
49   php-curl
50 ]
51
52 directory "/opt/planet-dump-ng" do
53   owner "root"
54   group "root"
55   mode "755"
56 end
57
58 git "/opt/planet-dump-ng" do
59   action :sync
60   repository "https://github.com/zerebubuth/planet-dump-ng.git"
61   revision "v1.1.8"
62   depth 1
63   user "root"
64   group "root"
65 end
66
67 execute "/opt/planet-dump-ng/autogen.sh" do
68   action :nothing
69   command "./autogen.sh"
70   cwd "/opt/planet-dump-ng"
71   user "root"
72   group "root"
73   subscribes :run, "git[/opt/planet-dump-ng]"
74 end
75
76 execute "/opt/planet-dump-ng/configure" do
77   action :nothing
78   command "./configure"
79   cwd "/opt/planet-dump-ng"
80   user "root"
81   group "root"
82   subscribes :run, "execute[/opt/planet-dump-ng/autogen.sh]"
83 end
84
85 execute "/opt/planet-dump-ng/Makefile" do
86   action :nothing
87   command "make"
88   cwd "/opt/planet-dump-ng"
89   user "root"
90   group "root"
91   subscribes :run, "execute[/opt/planet-dump-ng/configure]"
92 end
93
94 directory "/store/planetdump" do
95   owner "www-data"
96   group "www-data"
97   mode "755"
98   recursive true
99 end
100
101 %w[planetdump planet-mirror-redirect-update].each do |program|
102   template "/usr/local/bin/#{program}" do
103     source "#{program}.erb"
104     owner "root"
105     group "root"
106     mode "755"
107   end
108 end
109
110 systemd_service "planetdump@" do
111   description "Planet dump for %i"
112   user "www-data"
113   exec_start "/usr/local/bin/planetdump %i"
114   memory_max "64G"
115   private_tmp true
116   private_devices true
117   private_network true
118   protect_system "full"
119   protect_home true
120   no_new_privileges true
121 end
122
123 cron_d "planet-dump-mirror" do
124   minute "*/10"
125   user "www-data"
126   command "/usr/local/bin/planet-mirror-redirect-update"
127   mailto "horntail-www-data-cron@firefishy.com"
128 end