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"]
146 trace_use_job_queue true
148 storage_configuration storage
149 avatar_storage "avatars"
150 trace_file_storage "gps_traces"
151 trace_image_storage "gps_images"
152 trace_icon_storage "gps_images"
153 avatar_storage_url "https://openstreetmap-user-avatars.s3.dualstack.eu-west-1.amazonaws.com"
154 trace_image_storage_url "https://openstreetmap-gps-images.s3.dualstack.eu-west-1.amazonaws.com"
155 overpass_url "https://query.openstreetmap.org/query-features"
156 overpass_credentials true
158 signup_ip_max_burst 48
159 signup_email_per_day 1
160 signup_email_max_burst 2
161 doorkeeper_signing_key web_passwords["openid_connect_key"].join("\n")
162 user_account_deletion_delay 7 * 24
163 # Requests to modify the imagery blacklist should come from the DWG only
165 # Current Google imagery URLs have google or googleapis in the domain
166 ".*\\.google(apis)?\\..*/.*",
168 "https?://xdworld\\.vworld\\.kr[/:].*",
170 ".*\\.here\\.com[/:].*",
174 ".*\\.api-maps\\.yandex\\.ru/.*",
175 ".*\\.maps\\.yandex\\.net/.*",
177 ".*\\.maps\\.2gis\\.com/.*"
181 systemd_service "rails-jobs@" do
182 description "Rails job queue runner"
184 environment "RAILS_ENV" => "production",
186 "SLEEP_DELAY" => "60",
187 "SECRET_KEY_BASE" => web_passwords["secret_key_base"]
189 working_directory rails_directory
190 exec_start "#{node[:ruby][:bundle]} exec rails jobs:work"
193 sandbox :enable_network => true
194 memory_deny_write_execute false
195 read_write_paths "/var/log/web"
198 package "libjson-xs-perl"
200 template "/usr/local/bin/cleanup-rails-assets" do
201 source "cleanup-assets.erb"
207 gem_package "apachelogregex" do
208 gem_binary node[:ruby][:gem]
211 gem_package "file-tail" do
212 gem_binary node[:ruby][:gem]
215 template "/usr/local/bin/api-statistics" do
216 source "api-statistics.erb"
222 systemd_service "api-statistics" do
223 description "OpenStreetMap API Statistics Daemon"
226 exec_start "/usr/local/bin/api-statistics"
230 "/srv/www.openstreetmap.org/rails/tmp",
231 "/var/lib/prometheus/node-exporter"
236 service "api-statistics" do
237 action [:enable, :start]
238 supports :restart => true
239 subscribes :restart, "template[/usr/local/bin/api-statistics]"
240 subscribes :restart, "systemd_service[api-statistics]"
243 gem_package "hpricot" do
244 gem_binary node[:ruby][:gem]