]> git.openstreetmap.org Git - chef.git/blob - cookbooks/cplanet/recipes/default.rb
Recipe to keep a local updated planet file.
[chef.git] / cookbooks / cplanet / recipes / default.rb
1 #
2 # Cookbook Name:: cplanet
3 # Recipe:: default
4 #
5 # Copyright 2018, 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 user = 'cplanet'
21 basedir = '/srv/cplanet'
22 planet_source = 'https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf'
23
24 package %w[
25   pyosmium
26 ]
27
28 directory basedir do
29   owner 'root'
30   group 'root'
31   mode 0o755
32 end
33
34 %w[bin jobs log].each do |dir|
35   directory "#{basedir}/#{dir}" do
36     owner 'root'
37     group 'root'
38     mode 0o755
39   end
40 end
41
42 directory "#{basedir}/planet" do
43   owner user
44   group user
45   mode 0o755
46 end
47
48 %w[update update-planet].each do |file|
49   template "#{basedir}/bin/#{file}" do
50     source "#{file}.erb"
51     owner 'root'
52     group 'root'
53     mode 0o755
54     variables :basedir => basedir, :user => user
55   end
56 end
57
58 remote_file "#{basedir}/planet/planet.pbf" do
59   action :create_if_missing
60   source planet_source
61   owner user
62   group user
63   mode 0o644
64 end
65
66 cron 'update-planet' do
67   hour 1
68   minute 17
69   user 'root'
70   command "#{basedir}/bin/update"
71 end
72