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"
23 include_recipe "passenger"
25 include_recipe "mysql"
26 include_recipe "postgresql"
37 package "php5-imagick"
44 package "python-argparse"
45 package "python-beautifulsoup"
46 package "python-cheetah"
47 package "python-dateutil"
48 package "python-magic"
49 package "python-psycopg2"
51 easy_install_package "geojson"
53 apache_module "expires"
54 apache_module "fastcgi-handler"
55 apache_module "rewrite"
56 apache_module "expires"
61 gem_package "rails" do
66 action [ :enable, :start ]
67 supports :status => true, :restart => true, :reload => true
70 template "/etc/php5/fpm/pool.d/default.conf" do
71 source "fpm-default.conf.erb"
75 notifies :reload, "service[php5-fpm]"
78 file "/etc/php5/fpm/pool.d/www.conf" do
80 notifies :reload, "service[php5-fpm]"
85 template "/etc/phppgadmin/config.inc.php" do
86 source "phppgadmin.conf.erb"
92 link "/etc/apache2/conf.d/phppgadmin" do
96 apache_site "phppgadmin.dev.openstreetmap.org" do
97 template "apache.phppgadmin.erb"
100 search(:accounts, "*:*").each do |account|
102 details = node[:accounts][:users][name] || {}
104 if ["user","administrator"].include?(details[:status])
105 user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name.to_s}"
107 if File.directory?("#{user_home}/public_html")
108 template "/etc/php5/fpm/pool.d/#{name}.conf" do
109 source "fpm.conf.erb"
113 variables :user => name
114 notifies :reload, "service[php5-fpm]"
117 apache_site "#{name}.dev.openstreetmap.org" do
118 template "apache.user.erb"
119 directory "#{user_home}/public_html"
120 variables :user => name
126 if node[:postgresql][:clusters][:"9.1/main"]
127 postgresql_user "apis" do
131 node[:dev][:rails].each do |name,details|
132 database_name = details[:database] || "apis_#{name}"
133 site_name = "#{name}.apis.dev.openstreetmap.org"
134 site_aliases = details[:aliases] || []
135 rails_directory = "/srv/#{name}.apis.dev.openstreetmap.org"
137 postgresql_database database_name do
142 postgresql_extension "#{database_name}_btree_gist" do
144 database database_name
145 extension "btree_gist"
148 rails_port site_name do
149 ruby node[:passenger][:ruby_version]
150 directory rails_directory
153 repository details[:repository]
154 revision details[:revision]
155 database_port node[:postgresql][:clusters][:"9.1/main"][:port]
156 database_name database_name
157 database_username "apis"
161 template "#{rails_directory}/config/initializers/setup.rb" do
162 source "rails.setup.rb.erb"
166 variables :site => site_name
167 notifies :touch, "file[#{rails_directory}/tmp/restart.txt]"
170 apache_site site_name do
171 template "apache.rails.erb"
172 variables :name => site_name, :aliases => site_aliases
176 Dir.glob("/srv/*.apis.dev.openstreetmap.org").each do |rails_directory|
177 name = File.basename(rails_directory, ".apis.dev.openstreetmap.org")
179 unless node[:dev][:rails].include?(name)
180 database_config = YAML.load_file("#{rails_directory}/config/database.yml")
181 database_name = database_config["production"]["database"]
182 site_name = "#{name}.apis.dev.openstreetmap.org"
184 apache_site site_name do
188 directory rails_directory do
193 file "/etc/cron.daily/rails-#{name}" do
197 postgresql_database database_name do
204 directory "/srv/apis.dev.openstreetmap.org" do
210 template "/srv/apis.dev.openstreetmap.org/index.html" do
211 source "apis.html.erb"
217 apache_site "apis.dev.openstreetmap.org" do
218 template "apache.apis.erb"
221 node[:postgresql][:clusters].each do |name,details|
222 postgresql_munin name do