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"
24 include_recipe "passenger"
36 libboost-program-options-dev
53 ruby_version = node[:passenger][:ruby_version]
55 package "ruby#{ruby_version}"
57 gem_package "bundler#{ruby_version}" do
58 package_name "bundler"
60 gem_binary "gem#{ruby_version}"
61 options "--format-executable"
65 apache_module "cache_disk"
66 apache_module "headers"
68 directory "/var/log/taginfo" do
74 template "/etc/sudoers.d/taginfo" do
81 node[:taginfo][:sites].each do |site|
82 site_name = site[:name]
83 site_aliases = Array(site[:aliases])
84 directory = site[:directory] || "/srv/#{site_name}"
85 description = site[:description]
88 contact = site[:contact]
90 directory "/var/log/taginfo/#{site_name}" do
96 directory directory do
102 git "#{directory}/taginfo-tools" do
104 repository "https://github.com/taginfo/taginfo-tools.git"
105 revision "osmorg-taginfo-live"
107 enable_submodules true
112 directory "#{directory}/build" do
118 execute "compile_taginfo_tools" do
122 cwd "#{directory}/build"
123 command "cmake #{directory}/taginfo-tools -DCMAKE_BUILD_TYPE=Release && make"
124 subscribes :run, "apt_package[libprotozero-dev]"
125 subscribes :run, "apt_package[libosmium2-dev]"
126 subscribes :run, "git[#{directory}/taginfo-tools]"
129 git "#{directory}/taginfo" do
131 repository "https://github.com/taginfo/taginfo.git"
132 revision "osmorg-taginfo-live"
138 settings = Chef::DelayedEvaluator.new do
139 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
141 settings["instance"]["url"] = "https://#{site_name}/"
142 settings["instance"]["description"] = description
143 settings["instance"]["about"] = about
144 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
145 settings["instance"]["contact"] = contact
146 settings["instance"]["access_control_allow_origin"] = ""
147 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
148 settings["opensearch"]["shortname"] = "Taginfo"
149 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
150 settings["paths"]["bin_dir"] = "#{directory}/build/src"
151 settings["sources"]["download"] = ""
152 settings["sources"]["create"] = "db languages projects wiki chronology"
153 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.osh.pbf"
154 settings["sources"]["chronology"]["osm_history_file"] = "/var/lib/planet/planet.osh.pbf"
155 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
157 JSON.pretty_generate(settings)
160 file "#{directory}/taginfo-config.json" do
165 notifies :restart, "service[apache2]"
168 execute "#{directory}/taginfo/Gemfile" do
170 command "bundle#{ruby_version} install"
171 cwd "#{directory}/taginfo"
174 subscribes :run, "gem_package[bundler#{ruby_version}]"
175 subscribes :run, "git[#{directory}/taginfo]"
176 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
179 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
180 directory "#{directory}/#{dir}" do
187 template "#{directory}/bin/update" do
192 variables :name => site_name, :directory => directory
195 passenger_application "#{directory}/taginfo/web/public" do
199 ssl_certificate site_name do
200 domains [site_name] + site_aliases
201 notifies :reload, "service[apache2]"
204 apache_site site_name do
205 template "apache.erb"
206 directory "#{directory}/taginfo/web/public"
207 variables :aliases => site_aliases
211 template "/usr/local/bin/taginfo-update" do
212 source "taginfo-update.erb"
216 variables :sites => node[:taginfo][:sites]