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 && 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["sources"]["download"] = ""
150 settings["sources"]["create"] = "db languages projects wiki"
151 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.pbf"
152 settings["sources"]["db"]["bindir"] = "#{directory}/build/src"
153 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
155 JSON.pretty_generate(settings)
158 file "#{directory}/taginfo-config.json" do
163 notifies :restart, "service[apache2]"
166 execute "#{directory}/taginfo/Gemfile" do
168 command "bundle#{ruby_version} install"
169 cwd "#{directory}/taginfo"
172 subscribes :run, "gem_package[bundler#{ruby_version}]"
173 subscribes :run, "git[#{directory}/taginfo]"
174 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
177 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
178 directory "#{directory}/#{dir}" do
185 template "#{directory}/bin/update" do
190 variables :name => site_name, :directory => directory
193 passenger_application "#{directory}/taginfo/web/public" do
197 ssl_certificate site_name do
198 domains [site_name] + site_aliases
199 notifies :reload, "service[apache2]"
202 apache_site site_name do
203 template "apache.erb"
204 directory "#{directory}/taginfo/web/public"
205 variables :aliases => site_aliases
209 template "/usr/local/bin/taginfo-update" do
210 source "taginfo-update.erb"
214 variables :sites => node[:taginfo][:sites]