]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/recipes/server.rb
Use volume for nested podman container storage
[chef.git] / cookbooks / chef / recipes / server.rb
1 #
2 # Cookbook:: chef
3 # Recipe:: server
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 include_recipe "apache"
21 include_recipe "chef::knife"
22
23 # cache_dir = Chef::Config[:file_cache_path]
24 #
25 # cinc_version = node[:chef][:server][:version]
26 #
27 # cinc_package = "cinc-server-core_#{cinc_version}-1_amd64.deb"
28 #
29 # os_release = node[:lsb][:release]
30 #
31 # Dir.glob("#{cache_dir}/cinc-server-core_*.deb").each do |deb|
32 #   next if deb == "#{cache_dir}/#{cinc_package}"
33 #
34 #   file deb do
35 #     action :delete
36 #     backup false
37 #   end
38 # end
39 #
40 # remote_file "#{cache_dir}/#{cinc_package}" do
41 #   source "https://downloads.cinc.sh/files/stable/cinc-server/#{cinc_version}/debian/#{os_release}/cinc-server-core_#{cinc_version}-1_amd64.deb"
42 #   owner "root"
43 #   group "root"
44 #   mode 0644
45 #   backup false
46 # end
47 #
48 # dpkg_package "cinc-server-core" do
49 #   source "#{cache_dir}/#{cinc_package}"
50 #   version "#{cinc_version}-1"
51 #   notifies :run, "execute[cinc-server-reconfigure]"
52 # end
53
54 template "/etc/cinc-project/cinc-server.rb" do
55   source "server.rb.erb"
56   owner "root"
57   group "root"
58   mode "640"
59   notifies :run, "execute[cinc-server-reconfigure]"
60 end
61
62 execute "cinc-server-reconfigure" do
63   action :nothing
64   command "cinc-server-ctl reconfigure"
65   user "root"
66   group "root"
67 end
68
69 execute "cinc-server-restart" do
70   action :nothing
71   command "cinc-server-ctl restart"
72   user "root"
73   group "root"
74 end
75
76 systemd_service "cinc-server" do
77   description "CINC server"
78   after "network.target"
79   exec_start "/opt/cinc-project/embedded/bin/runsvdir-start"
80 end
81
82 service "cinc-server" do
83   action [:enable, :start]
84   subscribes :restart, "systemd_service[cinc-server]"
85 end
86
87 apache_module "alias"
88 apache_module "proxy_http"
89
90 ssl_certificate "chef.openstreetmap.org" do
91   domains ["chef.openstreetmap.org", "chef.osm.org"]
92   notifies :reload, "service[apache2]"
93   notifies :run, "execute[cinc-server-restart]"
94 end
95
96 apache_site "chef.openstreetmap.org" do
97   template "apache.erb"
98 end
99
100 template "/etc/cron.daily/cinc-server-backup" do
101   source "server-backup.cron.erb"
102   owner "root"
103   group "root"
104   mode "755"
105 end