5 # Copyright:: 2014, 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.
22 include_recipe "accounts"
23 include_recipe "apache"
25 include_recipe "passenger"
26 include_recipe "planet::current"
27 include_recipe "prometheus"
39 libboost-program-options-dev
57 apache_module "cache_disk"
58 apache_module "headers"
60 directory "/var/log/taginfo" do
66 template "/etc/sudoers.d/taginfo" do
73 systemd_service "taginfo-update@" do
74 description "Taginfo update for %i"
75 wants "planet-update.service"
76 after "planet-update.service"
77 exec_start "/srv/%i/bin/update"
79 sandbox :enable_network => true
80 restrict_address_families "AF_UNIX"
89 systemd_timer "taginfo-update@" do
90 description "Taginfo update for %i"
94 node[:taginfo][:sites].each do |site|
95 site_name = site[:name]
96 site_aliases = Array(site[:aliases])
97 directory = site[:directory] || "/srv/#{site_name}"
98 description = site[:description]
101 contact = site[:contact]
103 directory "/var/log/taginfo/#{site_name}" do
109 directory directory do
115 git "#{directory}/taginfo-tools" do
117 repository "https://github.com/taginfo/taginfo-tools.git"
118 revision "osmorg-taginfo-live"
120 enable_submodules true
125 directory "#{directory}/build" do
131 execute "compile_taginfo_tools" do
135 cwd "#{directory}/build"
136 command "cmake #{directory}/taginfo-tools -DCMAKE_BUILD_TYPE=Release && make"
137 subscribes :run, "apt_package[libprotozero-dev]"
138 subscribes :run, "apt_package[libosmium2-dev]"
139 subscribes :run, "git[#{directory}/taginfo-tools]"
142 git "#{directory}/taginfo" do
144 repository "https://github.com/taginfo/taginfo.git"
145 revision "osmorg-taginfo-live"
151 settings = Chef::DelayedEvaluator.new do
152 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
154 settings["instance"]["url"] = "https://#{site_name}/"
155 settings["instance"]["description"] = description
156 settings["instance"]["about"] = about
157 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
158 settings["instance"]["contact"] = contact
159 settings["instance"]["access_control_allow_origin"] = ""
160 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
161 settings["opensearch"]["shortname"] = "Taginfo"
162 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
163 settings["paths"]["bin_dir"] = "#{directory}/build/src"
164 settings["sources"]["download"] = ""
165 settings["sources"]["create"] = "db languages projects wiki wikidata chronology"
166 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.osh.pbf"
167 settings["sources"]["chronology"]["osm_history_file"] = "/var/lib/planet/planet.osh.pbf"
168 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
170 JSON.pretty_generate(settings)
173 file "#{directory}/taginfo-config.json" do
178 notifies :restart, "service[apache2]"
181 bundle_install "#{directory}/taginfo" do
185 subscribes :run, "git[#{directory}/taginfo]"
186 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
189 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
190 directory "#{directory}/#{dir}" do
197 template "#{directory}/bin/update" do
202 variables :name => site_name, :directory => directory
205 passenger_application "#{directory}/taginfo/web/public" do
209 ssl_certificate site_name do
210 domains [site_name] + site_aliases
211 notifies :reload, "service[apache2]"
214 apache_site site_name do
215 template "apache.erb"
216 directory "#{directory}/taginfo/web/public"
217 variables :aliases => site_aliases
220 service "taginfo-update@#{site_name}.timer" do
221 action [:enable, :start]
224 prometheus_collector "taginfo-#{site_name}" do
227 path "#{directory}/taginfo/sources/metrics.rb"
228 options "#{directory}/data"