]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/recipes/rails.rb
Don't use ||= in attributes files as it doesn't work
[chef.git] / cookbooks / web / recipes / rails.rb
1 #
2 # Cookbook Name:: web
3 # Recipe:: rails
4 #
5 # Copyright 2011, 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 "tools"
21 include_recipe "web::base"
22
23 include_recipe "apache"
24 include_recipe "git"
25
26 web_passwords = data_bag_item("web", "passwords")
27 db_passwords = data_bag_item("db", "passwords")
28
29 directory "#{node[:web][:base_directory]}/bin" do
30   owner "root"
31   group "root"
32   mode 0755
33 end
34
35 template "#{node[:web][:base_directory]}/bin/ruby" do
36   source "ruby.erb"
37   owner "root"
38   group "root"
39   mode 0755
40   notifies :reload, "service[apache2]"
41 end
42
43 apache_module "passenger" do
44   conf "passenger.conf.erb"
45 end
46
47 package "passenger-common#{node[:web][:ruby_version]}"
48
49 munin_plugin "passenger_memory"
50 munin_plugin "passenger_processes"
51 munin_plugin "passenger_queues"
52 munin_plugin "passenger_requests"
53
54 template "/etc/cron.hourly/passenger" do
55   cookbook "web"
56   source "passenger.cron.erb"
57   owner "root"
58   group "root"
59   mode 0755
60 end
61
62 rails_directory = "#{node[:web][:base_directory]}/rails"
63
64 piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,v|
65   ["chef_type", "data_bag", "id"].include?(k)
66 end
67
68 rails_port "www.openstreetmap.org" do
69   ruby node[:web][:ruby_version]
70   directory rails_directory
71   user "rails"
72   group "rails"
73   repository "git://git.openstreetmap.org/rails.git"
74   revision "live"
75   database_host node[:web][:database_host]
76   database_name "openstreetmap"
77   database_username "rails"
78   database_password db_passwords["rails"]
79   email_from "OpenStreetMap <web@noreply.openstreetmap.org>"
80   status node[:web][:status]
81   messages_domain "messages.openstreetmap.org"
82   quova_username "ws360602"
83   quova_password web_passwords["quova"]
84   soft_memory_limit node[:web][:rails_soft_memory_limit]
85   hard_memory_limit node[:web][:rails_hard_memory_limit]
86   gpx_dir "/store/rails/gpx"
87   attachments_dir "/store/rails/attachments"
88   log_path "#{node[:web][:log_directory]}/rails.log"
89   memcache_servers [ "rails1", "rails2", "rails3" ]
90   potlatch2_key web_passwords["potlatch2_key"]
91   id_key web_passwords["id_key"]
92   oauth_key web_passwords["oauth_key"]
93   piwik_configuration piwik_configuration
94 end