]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/recipes/server.rb
Fix more rubocop detected style issues
[chef.git] / cookbooks / chef / recipes / server.rb
1 #
2 # Cookbook Name:: 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 #     http://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::ssl"
21
22 chef_platform = case node[:platform_version]
23                 when "12.10" then "12.04"
24                 when "14.04" then "12.04"
25                 else node[:platform_version]
26                 end
27
28 chef_package = "chef-server_#{node[:chef][:server][:version]}_amd64.deb"
29
30 directory "/var/cache/chef" do
31   owner "root"
32   group "root"
33   mode 0755
34 end
35
36 Dir.glob("/var/cache/chef/chef-server_*.deb").each do |deb|
37   if deb != "/var/cache/chef/#{chef_package}"
38     file deb do
39       action :delete
40       backup false
41     end
42   end
43 end
44
45 remote_file "/var/cache/chef/#{chef_package}" do
46   source "https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/#{chef_platform}/x86_64/#{chef_package}"
47   owner "root"
48   group "root"
49   mode 0644
50   backup false
51 end
52
53 dpkg_package "chef-erver" do
54   source "/var/cache/chef/#{chef_package}"
55   version node[:chef][:server][:version]
56   notifies :run, "execute[chef-server-reconfigure]"
57 end
58
59 ruby_block "/opt/chef-server/embedded/service/chef-server-webui/app/controllers/status_controller.rb" do
60   block do
61     rc = Chef::Util::FileEdit.new("/opt/chef-server/embedded/service/chef-server-webui/app/controllers/status_controller.rb")
62     rc.search_file_delete(/&rows=20/)
63     rc.write_file
64
65     if rc.file_edited?
66       resources(:execute => "chef-server-reconfigure").run_action(:run)
67     end
68   end
69 end
70
71 template "/etc/chef-server/chef-server.rb" do
72   source "server.rb.erb"
73   owner "root"
74   group "root"
75   mode 0644
76   notifies :run, "execute[chef-server-reconfigure]"
77 end
78
79 execute "chef-server-reconfigure" do
80   action :nothing
81   command "chef-server-ctl reconfigure"
82   user "root"
83   group "root"
84 end
85
86 service "chef-server-runsvdir" do
87   provider Chef::Provider::Service::Upstart
88   action [ :enable, :start ]
89   supports :status => true, :restart => true, :reload => true
90 end
91
92 apache_module "alias"
93 apache_module "proxy_http"
94
95 apache_site "chef.openstreetmap.org" do
96   template "apache.erb"
97 end
98
99 template "/etc/cron.daily/chef-server-backup" do
100   source "server-backup.cron.erb"
101   owner "root"
102   group "root"
103   mode 0755
104 end