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 # https://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.
20 include_recipe "apache"
23 include_recipe "geoipupdate"
24 include_recipe "nodejs"
25 include_recipe "passenger"
27 include_recipe "tools"
28 include_recipe "web::base"
30 web_passwords = data_bag_item("web", "passwords")
31 db_passwords = data_bag_item("db", "passwords")
33 ssl_certificate "www.openstreetmap.org" do
34 domains ["www.openstreetmap.org", "www.osm.org", "www.openstreetmap.com",
35 "api.openstreetmap.org", "api.osm.org",
36 "maps.openstreetmap.org", "maps.osm.org",
37 "mapz.openstreetmap.org", "mapz.osm.org",
38 "openstreetmap.org", "osm.org", "openstreetmap.com"]
39 notifies :reload, "service[apache2]"
44 rails_directory = "#{node[:web][:base_directory]}/rails"
46 matomo = data_bag_item("web", "matomo")
48 aws_access_key_id = "AKIASQUXHPE7AMJQRFOS"
49 aws_secret_access_key = web_passwords["aws_keys"][aws_access_key_id]
54 "access_key_id" => aws_access_key_id,
55 "secret_access_key" => aws_secret_access_key,
56 "region" => "eu-west-1",
57 "bucket" => "openstreetmap-user-avatars",
59 "use_dualstack_endpoint" => true,
61 "acl" => "public-read",
62 "cache_control" => "public, max-age=31536000, immutable"
67 "access_key_id" => aws_access_key_id,
68 "secret_access_key" => aws_secret_access_key,
69 "region" => "eu-west-1",
70 "bucket" => "openstreetmap-gps-traces",
71 "use_dualstack_endpoint" => true,
74 "acl" => "public-read",
75 "cache_control" => "public, max-age=31536000, immutable"
80 "access_key_id" => aws_access_key_id,
81 "secret_access_key" => aws_secret_access_key,
82 "region" => "eu-west-1",
83 "bucket" => "openstreetmap-gps-images",
84 "use_dualstack_endpoint" => true,
87 "acl" => "public-read",
88 "cache_control" => "public, max-age=31536000, immutable"
93 db_host = if node[:web][:status] == "database_readonly"
94 node[:web][:readonly_database_host]
96 node[:web][:database_host]
99 rails_port "www.openstreetmap.org" do
100 directory rails_directory
103 repository "https://git.openstreetmap.org/public/rails.git"
105 database_host db_host
106 database_name "openstreetmap"
107 database_username "rails"
108 database_password db_passwords["rails"]
109 email_from "OpenStreetMap <web@noreply.openstreetmap.org>"
110 status node[:web][:status]
111 messages_domain "messages.openstreetmap.org"
112 log_path "#{node[:web][:log_directory]}/rails.log"
113 memcache_servers node[:web][:memcached_servers]
114 potlatch2_key web_passwords["potlatch2_key"]
115 id_key web_passwords["id_key"]
116 id_application web_passwords["id_application"]
117 oauth_key web_passwords["oauth_key"]
118 oauth_application web_passwords["oauth_application"]
119 matomo_configuration "location" => matomo[:location],
120 "site" => matomo[:site],
121 "visitor_cookie_timeout" => matomo[:visitor_cookie_timeout],
122 "referral_cookie_timeout" => matomo[:referral_cookie_timeout],
123 "session_cookie_timeout" => matomo[:session_cookie_timeout],
124 "goals" => matomo[:goals].to_hash
125 google_auth_id "651529786092-6c5ahcu0tpp95emiec8uibg11asmk34t.apps.googleusercontent.com"
126 google_auth_secret web_passwords["google_auth_secret"]
127 google_openid_realm "https://www.openstreetmap.org"
128 apple_auth_id "org.openstreetmap.www"
129 apple_team_id "MF99FFFD4L"
130 apple_key_id "73A2H3M7J3"
131 apple_private_key web_passwords["apple_private_key"].join("\n")
132 facebook_auth_id "427915424036881"
133 facebook_auth_secret web_passwords["facebook_auth_secret"]
134 microsoft_auth_id "e34f14f1-f790-40f3-9fa4-3c5f1a027c38"
135 microsoft_auth_secret web_passwords["microsoft_auth_secret"]
136 github_auth_id "acf7da34edee99e35499"
137 github_auth_secret web_passwords["github_auth_secret"]
138 wikipedia_auth_id "e4fe0c2c5855d23ed7e1f1c0fa1f1c58"
139 wikipedia_auth_secret web_passwords["wikipedia_auth_secret"]
140 thunderforest_key web_passwords["thunderforest_key"]
141 tracestrack_key web_passwords["tracestrack_key"]
142 maptiler_key web_passwords["maptiler_key"]
143 totp_key web_passwords["totp_key"]
145 trace_use_job_queue true
147 storage_configuration storage
148 avatar_storage "avatars"
149 trace_file_storage "gps_traces"
150 trace_image_storage "gps_images"
151 trace_icon_storage "gps_images"
152 avatar_storage_url "https://openstreetmap-user-avatars.s3.dualstack.eu-west-1.amazonaws.com"
153 trace_image_storage_url "https://openstreetmap-gps-images.s3.dualstack.eu-west-1.amazonaws.com"
154 overpass_url "https://query.openstreetmap.org/query-features"
155 overpass_credentials true
157 signup_ip_max_burst 48
158 signup_email_per_day 1
159 signup_email_max_burst 2
160 doorkeeper_signing_key web_passwords["openid_connect_key"].join("\n")
161 user_account_deletion_delay 7 * 24
162 # Requests to modify the imagery blacklist should come from the DWG only
164 # Current Google imagery URLs have google or googleapis in the domain
165 ".*\\.google(apis)?\\..*/.*",
167 "https?://xdworld\\.vworld\\.kr[/:].*",
169 ".*\\.here\\.com[/:].*",
173 ".*\\.api-maps\\.yandex\\.ru/.*",
174 ".*\\.maps\\.yandex\\.net/.*",
176 ".*\\.maps\\.2gis\\.com/.*"
180 systemd_service "rails-jobs@" do
181 description "Rails job queue runner"
183 environment "RAILS_ENV" => "production",
185 "SLEEP_DELAY" => "60",
186 "SECRET_KEY_BASE" => web_passwords["secret_key_base"]
188 working_directory rails_directory
189 exec_start "#{node[:ruby][:bundle]} exec rails jobs:work"
192 sandbox :enable_network => true
193 memory_deny_write_execute false
194 read_write_paths "/var/log/web"
197 package "libjson-xs-perl"
199 template "/usr/local/bin/cleanup-rails-assets" do
200 source "cleanup-assets.erb"
206 gem_package "apachelogregex" do
207 gem_binary node[:ruby][:gem]
210 gem_package "file-tail" do
211 gem_binary node[:ruby][:gem]
214 template "/usr/local/bin/api-statistics" do
215 source "api-statistics.erb"
221 systemd_service "api-statistics" do
222 description "OpenStreetMap API Statistics Daemon"
225 exec_start "/usr/local/bin/api-statistics"
229 "/srv/www.openstreetmap.org/rails/tmp",
230 "/var/lib/prometheus/node-exporter"
235 service "api-statistics" do
236 action [:enable, :start]
237 supports :restart => true
238 subscribes :restart, "template[/usr/local/bin/api-statistics]"
239 subscribes :restart, "systemd_service[api-statistics]"
242 gem_package "hpricot" do
243 gem_binary node[:ruby][:gem]