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