]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/recipes/notes.rb
Add planet::aws recipe to configure awscli for planet uploads
[chef.git] / cookbooks / planet / recipes / notes.rb
1 #
2 # Cookbook:: planet
3 # Recipe:: notes
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 include_recipe "planet::aws"
23
24 db_passwords = data_bag_item("db", "passwords")
25
26 package %w[
27   pbzip2
28   python3
29   python3-psycopg2
30   python3-lxml
31 ]
32
33 directory "/opt/planet-notes-dump" do
34   owner "root"
35   group "root"
36   mode "755"
37 end
38
39 git "/opt/planet-notes-dump" do
40   action :sync
41   repository "https://github.com/openstreetmap/planet-notes-dump.git"
42   depth 1
43   user "root"
44   group "root"
45 end
46
47 template "/usr/local/bin/planet-notes-dump" do
48   source "planet-notes-dump.erb"
49   owner "root"
50   group "root"
51   mode "755"
52   variables :password => db_passwords["planetdump"]
53 end
54
55 systemd_service "planet-notes-dump" do
56   description "Create notes dump"
57   exec_start "/usr/local/bin/planet-notes-dump"
58   user "planet"
59   sandbox :enable_network => true
60   read_write_paths "/store/planet/notes"
61 end
62
63 systemd_timer "planet-notes-dump" do
64   description "Create notes dump"
65   on_calendar "03:00"
66 end
67
68 service "planet-notes-dump.timer" do
69   action [:enable, :start]
70 end
71
72 template "/usr/local/bin/planet-notes-cleanup" do
73   source "planet-notes-cleanup.erb"
74   owner "root"
75   group "root"
76   mode "755"
77 end
78
79 systemd_service "planet-notes-cleanup" do
80   description "Delete old notes dumps"
81   exec_start "/usr/local/bin/planet-notes-cleanup"
82   user "planet"
83   sandbox true
84   read_write_paths "/store/planet/notes"
85 end
86
87 systemd_timer "planet-notes-cleanup" do
88   description "Delete old notes dumps"
89   on_calendar "08:10"
90 end
91
92 service "planet-notes-cleanup.timer" do
93   action [:enable, :start]
94 end