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"
38 libboost-program-options-dev
56 apache_module "cache_disk"
57 apache_module "headers"
59 directory "/var/log/taginfo" do
65 template "/etc/sudoers.d/taginfo" do
72 systemd_service "taginfo-update@" do
73 description "Taginfo update for %i"
74 wants "planet-update.service"
75 after "planet-update.service"
76 exec_start "/srv/%i/bin/update"
78 sandbox :enable_network => true
79 restrict_address_families "AF_UNIX"
88 systemd_timer "taginfo-update@" do
89 description "Taginfo update for %i"
93 node[:taginfo][:sites].each do |site|
94 site_name = site[:name]
95 site_aliases = Array(site[:aliases])
96 directory = site[:directory] || "/srv/#{site_name}"
97 description = site[:description]
100 contact = site[:contact]
102 directory "/var/log/taginfo/#{site_name}" do
108 directory directory do
114 git "#{directory}/taginfo-tools" do
116 repository "https://github.com/taginfo/taginfo-tools.git"
117 revision "osmorg-taginfo-live"
119 enable_submodules true
124 directory "#{directory}/build" do
130 execute "compile_taginfo_tools" do
134 cwd "#{directory}/build"
135 command "cmake #{directory}/taginfo-tools -DCMAKE_BUILD_TYPE=Release && make"
136 subscribes :run, "apt_package[libprotozero-dev]"
137 subscribes :run, "apt_package[libosmium2-dev]"
138 subscribes :run, "git[#{directory}/taginfo-tools]"
141 git "#{directory}/taginfo" do
143 repository "https://github.com/taginfo/taginfo.git"
144 revision "osmorg-taginfo-live"
150 settings = Chef::DelayedEvaluator.new do
151 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
153 settings["instance"]["url"] = "https://#{site_name}/"
154 settings["instance"]["description"] = description
155 settings["instance"]["about"] = about
156 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
157 settings["instance"]["contact"] = contact
158 settings["instance"]["access_control_allow_origin"] = ""
159 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
160 settings["opensearch"]["shortname"] = "Taginfo"
161 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
162 settings["paths"]["bin_dir"] = "#{directory}/build/src"
163 settings["sources"]["download"] = ""
164 settings["sources"]["create"] = "db languages projects wiki chronology"
165 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.osh.pbf"
166 settings["sources"]["chronology"]["osm_history_file"] = "/var/lib/planet/planet.osh.pbf"
167 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
169 JSON.pretty_generate(settings)
172 file "#{directory}/taginfo-config.json" do
177 notifies :restart, "service[apache2]"
180 bundle_install "#{directory}/taginfo" do
184 subscribes :run, "git[#{directory}/taginfo]"
185 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
188 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
189 directory "#{directory}/#{dir}" do
196 template "#{directory}/bin/update" do
201 variables :name => site_name, :directory => directory
204 passenger_application "#{directory}/taginfo/web/public" do
208 ssl_certificate site_name do
209 domains [site_name] + site_aliases
210 notifies :reload, "service[apache2]"
213 apache_site site_name do
214 template "apache.erb"
215 directory "#{directory}/taginfo/web/public"
216 variables :aliases => site_aliases
219 service "taginfo-update@#{site_name}.timer" do
220 action [:enable, :start]