5 # Copyright 2011, OpenStreetMap Foundation
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
22 include_recipe "apache"
24 include_recipe "mysql"
25 include_recipe "postgresql"
36 package "php5-imagick"
43 package "python-argparse"
44 package "python-beautifulsoup"
45 package "python-cheetah"
46 package "python-dateutil"
47 package "python-magic"
48 package "python-psycopg2"
50 apache_module "expires"
51 apache_module "fastcgi-handler"
52 apache_module "rewrite"
53 apache_module "expires"
56 apache_module "passenger" do
57 conf "passenger.conf.erb"
60 munin_plugin "passenger_memory"
61 munin_plugin "passenger_processes"
62 munin_plugin "passenger_queues"
63 munin_plugin "passenger_requests"
67 gem_package "rails" do
72 action [ :enable, :start ]
73 supports :status => true, :restart => true, :reload => true
76 template "/etc/php5/fpm/pool.d/default.conf" do
77 source "fpm-default.conf.erb"
81 notifies :reload, resources(:service => "php5-fpm")
84 file "/etc/php5/fpm/pool.d/www.conf" do
86 notifies :reload, resources(:service => "php5-fpm")
91 template "/etc/phppgadmin/config.inc.php" do
92 source "phppgadmin.conf.erb"
98 link "/etc/apache2/conf.d/phppgadmin" do
102 apache_site "phppgadmin.dev.openstreetmap.org" do
103 template "apache.phppgadmin.erb"
106 node[:accounts][:users].each do |name,details|
107 if ["user","administrator"].include?(details[:status])
108 user_home = details[:home] || "#{node[:accounts][:home]}/#{name.to_s}"
110 if File.directory?("#{user_home}/public_html")
111 template "/etc/php5/fpm/pool.d/#{name}.conf" do
112 source "fpm.conf.erb"
116 variables :user => name
117 notifies :reload, resources(:service => "php5-fpm")
120 apache_site "#{name}.dev.openstreetmap.org" do
121 template "apache.user.erb"
122 directory "#{user_home}/public_html"
123 variables :user => name
129 if node[:postgresql][:clusters]["9.1/main"]
130 postgresql_user "apis" do
134 node[:dev][:rails].each do |name,details|
135 database_name = details[:database] || "apis_#{name}"
136 site_name = "#{name}.apis.dev.openstreetmap.org"
137 site_aliases = details[:aliases] || []
138 rails_directory = "/srv/#{name}.apis.dev.openstreetmap.org"
140 postgresql_database database_name do
145 postgresql_extension "#{database_name}_btree_gist" do
147 database database_name
148 extension "btree_gist"
151 rails_port site_name do
152 ruby node[:dev][:ruby]
153 directory rails_directory
156 repository details[:repository]
157 revision details[:revision]
158 database_port node[:postgresql][:clusters]["9.1/main"][:port]
159 database_name database_name
160 database_username "apis"
164 template "#{rails_directory}/config/initializers/setup.rb" do
165 source "rails.setup.rb.erb"
169 variables :site => site_name
170 notifies :touch, resources(:file => "#{rails_directory}/tmp/restart.txt")
173 apache_site site_name do
174 template "apache.rails.erb"
175 variables :name => site_name, :aliases => site_aliases
179 Dir.glob("/srv/*.apis.dev.openstreetmap.org").each do |rails_directory|
180 name = File.basename(rails_directory, ".apis.dev.openstreetmap.org")
182 unless node[:dev][:rails].include?(name)
183 database_config = YAML.load_file("#{rails_directory}/config/database.yml")
184 database_name = database_config["production"]["database"]
185 site_name = "#{name}.apis.dev.openstreetmap.org"
187 apache_site site_name do
191 directory rails_directory do
196 file "/etc/cron.daily/rails-#{name}" do
200 postgresql_database database_name do
207 directory "/srv/apis.dev.openstreetmap.org" do
213 template "/srv/apis.dev.openstreetmap.org/index.html" do
214 source "apis.html.erb"
220 apache_site "apis.dev.openstreetmap.org" do
221 template "apache.apis.erb"
224 node[:postgresql][:clusters].each do |name,details|
225 postgresql_munin name do