]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/recipes/default.rb
Use volume for nested podman container storage
[chef.git] / cookbooks / chef / recipes / default.rb
1 #
2 # Cookbook:: chef
3 # Recipe:: default
4 #
5 # Copyright:: 2010, 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 cache_dir = Chef::Config[:file_cache_path]
21
22 cinc_version = node[:chef][:client][:version]
23
24 cinc_platform = if platform?("debian")
25                   "debian"
26                 else
27                   "ubuntu"
28                 end
29
30 cinc_arch = if arm?
31               "arm64"
32             else
33               "amd64"
34             end
35
36 os_release = node[:lsb][:release]
37
38 cinc_package = "cinc_#{cinc_version}-1_#{cinc_arch}.deb"
39
40 Dir.glob("#{cache_dir}/cinc_*.deb").each do |deb|
41   next if deb == "#{cache_dir}/#{cinc_package}"
42
43   file deb do
44     action :delete
45     backup false
46   end
47 end
48
49 remote_file "#{cache_dir}/#{cinc_package}" do
50   source "https://downloads.cinc.sh/files/stable/cinc/#{cinc_version}/#{cinc_platform}/#{os_release}/#{cinc_package}"
51   owner "root"
52   group "root"
53   mode "644"
54   backup false
55   ignore_failure true
56 end
57
58 dpkg_package "cinc" do
59   source "#{cache_dir}/#{cinc_package}"
60   version "#{cinc_version}-1"
61 end
62
63 directory "/etc/cinc" do
64   owner "root"
65   group "root"
66   mode "755"
67 end
68
69 template "/etc/cinc/client.rb" do
70   source "client.rb.erb"
71   owner "root"
72   group "root"
73   mode "640"
74 end
75
76 file "/etc/cinc/client.pem" do
77   owner "root"
78   group "root"
79   mode "400"
80 end
81
82 template "/etc/cinc/report.rb" do
83   source "report.rb.erb"
84   owner "root"
85   group "root"
86   mode "644"
87 end
88
89 package "logrotate"
90
91 template "/etc/logrotate.d/cinc" do
92   source "logrotate.erb"
93   owner "root"
94   group "root"
95   mode "644"
96 end
97
98 directory "/var/log/cinc" do
99   owner "root"
100   group "root"
101   mode "755"
102 end
103
104 systemd_service "cinc-client" do
105   description "Cinc client"
106   exec_start "/usr/bin/cinc-client"
107   nice 10
108 end
109
110 systemd_timer "cinc-client" do
111   description "Cinc client"
112   after "network.target"
113   on_active_sec 60
114   on_unit_inactive_sec 25 * 60
115   randomized_delay_sec 10 * 60
116 end
117
118 service "cinc-client.timer" do
119   action [:enable, :start]
120 end