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