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