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")
32 aws_credentials = data_bag_item("web", "aws")
34 ssl_certificate "www.openstreetmap.org" do
35 domains ["www.openstreetmap.org", "www.osm.org", "www.openstreetmap.com",
36 "api.openstreetmap.org", "api.osm.org",
37 "maps.openstreetmap.org", "maps.osm.org",
38 "mapz.openstreetmap.org", "mapz.osm.org",
39 "openstreetmap.org", "osm.org", "openstreetmap.com"]
40 notifies :reload, "service[apache2]"
45 rails_directory = "#{node[:web][:base_directory]}/rails"
47 matomo = data_bag_item("web", "matomo")
49 aws_access_key_id = aws_credentials["web_access_key_id"]
50 aws_secret_access_key = aws_credentials["web_secret_access_key"]
55 "access_key_id" => aws_access_key_id,
56 "secret_access_key" => aws_secret_access_key,
57 "region" => "eu-west-1",
58 "bucket" => "openstreetmap-user-avatars",
60 "use_dualstack_endpoint" => true,
62 "acl" => "public-read",
63 "cache_control" => "public, max-age=31536000, immutable"
68 "access_key_id" => aws_access_key_id,
69 "secret_access_key" => aws_secret_access_key,
70 "region" => "eu-west-1",
71 "bucket" => "openstreetmap-gps-traces",
72 "use_dualstack_endpoint" => true,
75 "acl" => "public-read",
76 "cache_control" => "public, max-age=31536000, immutable"
81 "access_key_id" => aws_access_key_id,
82 "secret_access_key" => aws_secret_access_key,
83 "region" => "eu-west-1",
84 "bucket" => "openstreetmap-gps-images",
85 "use_dualstack_endpoint" => true,
88 "acl" => "public-read",
89 "cache_control" => "public, max-age=31536000, immutable"
94 db_host = if node[:web][:status] == "database_readonly"
95 node[:web][:readonly_database_host]
97 node[:web][:database_host]
100 rails_port "www.openstreetmap.org" do
101 directory rails_directory
104 repository "https://git.openstreetmap.org/public/rails.git"
106 database_host db_host
107 database_name "openstreetmap"
108 database_username "rails"
109 database_password db_passwords["rails"]
110 email_from "OpenStreetMap <web@noreply.openstreetmap.org>"
111 status node[:web][:status]
112 messages_domain "messages.openstreetmap.org"
113 log_path "#{node[:web][:log_directory]}/rails.log"
114 memcache_servers node[:web][:memcached_servers]
115 potlatch2_key web_passwords["potlatch2_key"]
116 id_key web_passwords["id_key"]
117 id_application web_passwords["id_application"]
118 oauth_key web_passwords["oauth_key"]
119 oauth_application web_passwords["oauth_application"]
120 matomo_configuration "location" => matomo[:location],
121 "site" => matomo[:site],
122 "visitor_cookie_timeout" => matomo[:visitor_cookie_timeout],
123 "referral_cookie_timeout" => matomo[:referral_cookie_timeout],
124 "session_cookie_timeout" => matomo[:session_cookie_timeout],
125 "goals" => matomo[:goals].to_hash
126 google_auth_id "651529786092-6c5ahcu0tpp95emiec8uibg11asmk34t.apps.googleusercontent.com"
127 google_auth_secret web_passwords["google_auth_secret"]
128 google_openid_realm "https://www.openstreetmap.org"
129 apple_auth_id "org.openstreetmap.www"
130 apple_team_id "MF99FFFD4L"
131 apple_key_id "73A2H3M7J3"
132 apple_private_key web_passwords["apple_private_key"].join("\n")
133 facebook_auth_id "427915424036881"
134 facebook_auth_secret web_passwords["facebook_auth_secret"]
135 microsoft_auth_id "e34f14f1-f790-40f3-9fa4-3c5f1a027c38"
136 microsoft_auth_secret web_passwords["microsoft_auth_secret"]
137 github_auth_id "acf7da34edee99e35499"
138 github_auth_secret web_passwords["github_auth_secret"]
139 wikipedia_auth_id "e4fe0c2c5855d23ed7e1f1c0fa1f1c58"
140 wikipedia_auth_secret web_passwords["wikipedia_auth_secret"]
141 thunderforest_key web_passwords["thunderforest_key"]
142 tracestrack_key web_passwords["tracestrack_key"]
143 maptiler_key web_passwords["maptiler_key"]
144 totp_key web_passwords["totp_key"]
145 totp_domain "openstreetmap.org"
147 trace_use_job_queue true
149 storage_configuration storage
150 avatar_storage "avatars"
151 trace_file_storage "gps_traces"
152 trace_image_storage "gps_images"
153 trace_icon_storage "gps_images"
154 avatar_storage_url "https://openstreetmap-user-avatars.s3.dualstack.eu-west-1.amazonaws.com"
155 trace_image_storage_url "https://openstreetmap-gps-images.s3.dualstack.eu-west-1.amazonaws.com"
156 overpass_url "https://query.openstreetmap.org/query-features"
157 overpass_credentials true
159 signup_ip_max_burst 48
160 signup_email_per_day 1
161 signup_email_max_burst 2
162 doorkeeper_signing_key web_passwords["openid_connect_key"].join("\n")
163 user_account_deletion_delay 7 * 24
164 turnstile_site_key "0x4AAAAAACsSjCdlK-9Cu3FO"
165 turnstile_secret_key web_passwords["cloudflare_turnstile_secret"]
166 # Requests to modify the imagery blacklist should come from the DWG only
168 # Current Google imagery URLs have google or googleapis in the domain
169 ".*\\.google(apis)?\\..*/.*",
171 "https?://xdworld\\.vworld\\.kr[/:].*",
173 ".*\\.here\\.com[/:].*",
177 ".*\\.api-maps\\.yandex\\.ru/.*",
178 ".*\\.maps\\.yandex\\.net/.*",
180 ".*\\.maps\\.2gis\\.com/.*"
184 systemd_service "rails-jobs@" do
185 description "Rails job queue runner"
187 environment "RAILS_ENV" => "production",
189 "SLEEP_DELAY" => "60",
190 "SECRET_KEY_BASE" => web_passwords["secret_key_base"]
192 working_directory rails_directory
193 exec_start "#{node[:ruby][:bundle]} exec rails jobs:work"
198 sandbox :enable_network => true
199 memory_deny_write_execute false
200 read_write_paths "/var/log/web"
203 package "libjson-xs-perl"
205 template "/usr/local/bin/cleanup-rails-assets" do
206 source "cleanup-assets.erb"
212 gem_package "apachelogregex" do
213 gem_binary node[:ruby][:gem]
216 gem_package "file-tail" do
217 gem_binary node[:ruby][:gem]
220 template "/usr/local/bin/api-statistics" do
221 source "api-statistics.erb"
227 systemd_service "api-statistics" do
228 description "OpenStreetMap API Statistics Daemon"
231 exec_start "/usr/local/bin/api-statistics"
235 "/srv/www.openstreetmap.org/rails/tmp",
236 "/var/lib/prometheus/node-exporter"
241 service "api-statistics" do
242 action [:enable, :start]
243 supports :restart => true
244 subscribes :restart, "template[/usr/local/bin/api-statistics]"
245 subscribes :restart, "systemd_service[api-statistics]"
248 gem_package "hpricot" do
249 gem_binary node[:ruby][:gem]