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
52 ruby_version = node[:passenger][:ruby_version]
54 package "ruby#{ruby_version}"
56 gem_package "bundler#{ruby_version}" do
57 package_name "bundler"
59 gem_binary "gem#{ruby_version}"
60 options "--format-executable"
64 apache_module "cache_disk"
65 apache_module "headers"
67 directory "/var/log/taginfo" do
73 template "/etc/sudoers.d/taginfo" do
80 node[:taginfo][:sites].each do |site|
81 site_name = site[:name]
82 site_aliases = Array(site[:aliases])
83 directory = site[:directory] || "/srv/#{site_name}"
84 description = site[:description]
87 contact = site[:contact]
89 directory "/var/log/taginfo/#{site_name}" do
95 directory directory do
101 git "#{directory}/taginfo-tools" do
103 repository "https://github.com/taginfo/taginfo-tools.git"
104 revision "osmorg-taginfo-live"
106 enable_submodules true
111 directory "#{directory}/build" do
117 execute "compile_taginfo_tools" do
121 cwd "#{directory}/build"
122 command "cmake #{directory}/taginfo-tools -DCMAKE_BUILD_TYPE=Release && make"
123 subscribes :run, "apt_package[libprotozero-dev]"
124 subscribes :run, "apt_package[libosmium2-dev]"
125 subscribes :run, "git[#{directory}/taginfo-tools]"
128 git "#{directory}/taginfo" do
130 repository "https://github.com/taginfo/taginfo.git"
131 revision "osmorg-taginfo-live"
137 settings = Chef::DelayedEvaluator.new do
138 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
140 settings["instance"]["url"] = "https://#{site_name}/"
141 settings["instance"]["description"] = description
142 settings["instance"]["about"] = about
143 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
144 settings["instance"]["contact"] = contact
145 settings["instance"]["access_control_allow_origin"] = ""
146 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
147 settings["opensearch"]["shortname"] = "Taginfo"
148 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
149 settings["paths"]["bin_dir"] = "#{directory}/build/src"
150 settings["sources"]["download"] = ""
151 settings["sources"]["create"] = "db languages projects wiki chronology"
152 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.osh.pbf"
153 settings["sources"]["chronology"]["osm_history_file"] = "/var/lib/planet/planet.osh.pbf"
154 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
156 JSON.pretty_generate(settings)
159 file "#{directory}/taginfo-config.json" do
164 notifies :restart, "service[apache2]"
167 execute "#{directory}/taginfo/Gemfile" do
169 command "bundle#{ruby_version} install"
170 cwd "#{directory}/taginfo"
173 subscribes :run, "gem_package[bundler#{ruby_version}]"
174 subscribes :run, "git[#{directory}/taginfo]"
175 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
178 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
179 directory "#{directory}/#{dir}" do
186 template "#{directory}/bin/update" do
191 variables :name => site_name, :directory => directory
194 passenger_application "#{directory}/taginfo/web/public" do
198 ssl_certificate site_name do
199 domains [site_name] + site_aliases
200 notifies :reload, "service[apache2]"
203 apache_site site_name do
204 template "apache.erb"
205 directory "#{directory}/taginfo/web/public"
206 variables :aliases => site_aliases
210 template "/usr/local/bin/taginfo-update" do
211 source "taginfo-update.erb"
215 variables :sites => node[:taginfo][:sites]