]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tilelog/recipes/default.rb
Use volume for nested podman container storage
[chef.git] / cookbooks / tilelog / recipes / default.rb
1 #
2 # Cookbook:: tilelog
3 # Recipe:: default
4 #
5 # Copyright:: 2014-2022, 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 "planet::aws"
22 include_recipe "python"
23
24 aws_credentials = data_bag_item("tilelog", "aws")
25
26 tilelog_directory = "/opt/tilelog"
27 ofastlylog_directory = "/opt/ofastlylog"
28 tilelog_output_directory = node[:tilelog][:output_directory]
29
30 python_virtualenv tilelog_directory do
31   interpreter "/usr/bin/python3"
32 end
33
34 python_package "tilelog" do
35   python_virtualenv tilelog_directory
36   python_version "3"
37   version "1.8.0"
38 end
39
40 directory tilelog_output_directory do
41   user "planet"
42   group "planet"
43   mode "755"
44   recursive true
45 end
46
47 template "/usr/local/bin/tilelog" do
48   source "tilelog.erb"
49   owner "root"
50   group "root"
51   mode "755"
52   variables :output_dir => tilelog_output_directory,
53             :aws_credentials => aws_credentials
54 end
55
56 systemd_service "tilelog" do
57   description "Tile log analysis"
58   user "planet"
59   exec_start "/usr/local/bin/tilelog"
60   nice 10
61   sandbox :enable_network => true
62   protect_home "tmpfs"
63   bind_paths "/home/planet"
64   read_write_paths tilelog_output_directory
65 end
66
67 systemd_timer "tilelog" do
68   description "Tile log analysis"
69   on_calendar "*-*-* 01:35:00"
70 end
71
72 service "tilelog.timer" do
73   action [:enable, :start]
74 end
75
76 python_virtualenv ofastlylog_directory do
77   interpreter "/usr/bin/python3"
78 end
79
80 python_package "ofastlylog" do
81   python_virtualenv ofastlylog_directory
82   python_version "3"
83   version "0.4.1"
84 end
85
86 template "/usr/local/bin/ofastlylog-hourly" do
87   source "ofastlylog-hourly.erb"
88   owner "root"
89   group "root"
90   mode "755"
91   variables :aws_credentials => aws_credentials
92 end
93
94 systemd_service "ofastlylog-hourly" do
95   description "ofastlylog analysis"
96   user "planet"
97   type "oneshot"
98   exec_start "/usr/local/bin/ofastlylog-hourly"
99   nice 10
100   sandbox :enable_network => true
101   protect_home true
102 end
103
104 systemd_timer "ofastlylog-hourly" do
105   description "Fastlylog log analysis"
106   on_calendar "*-*-* *:07:00"
107 end
108
109 service "ofastlylog-hourly.timer" do
110   action [:enable, :start]
111 end