2 # Cookbook Name:: taginfo
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 "apache"
23 include_recipe "passenger"
35 libboost-program-options-dev
51 ruby_version = node[:passenger][:ruby_version]
53 package "ruby#{ruby_version}"
55 gem_package "bundler#{ruby_version}" do
56 package_name "bundler"
57 gem_binary "gem#{ruby_version}"
58 options "--format-executable"
62 apache_module "cache_disk"
63 apache_module "headers"
65 template "/etc/cron.d/taginfo" do
72 directory "/var/log/taginfo" do
78 file "/etc/logrotate.d/taginfo" do
82 template "/etc/sudoers.d/taginfo" do
89 node[:taginfo][:sites].each do |site|
90 site_name = site[:name]
91 site_aliases = Array(site[:aliases])
92 directory = site[:directory] || "/srv/#{site_name}"
93 description = site[:description]
96 contact = site[:contact]
98 directory "/var/log/taginfo/#{site_name}" do
104 directory directory do
110 git "#{directory}/taginfo" do
112 repository "git://github.com/taginfo/taginfo.git"
113 revision "osmorg-taginfo-live"
118 settings = Chef::DelayedEvaluator.new do
119 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
121 settings["instance"]["url"] = "https://#{site_name}/"
122 settings["instance"]["description"] = description
123 settings["instance"]["about"] = about
124 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
125 settings["instance"]["contact"] = contact
126 settings["instance"]["access_control_allow_origin"] = ""
127 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
128 settings["opensearch"]["shortname"] = "Taginfo"
129 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
130 settings["sources"]["download"] = ""
131 settings["sources"]["create"] = "db languages projects wiki"
132 settings["sources"]["db"]["planetfile"] = "#{directory}/planet/planet.pbf"
133 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
134 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
136 JSON.pretty_generate(settings)
139 file "#{directory}/taginfo-config.json" do
144 notifies :restart, "service[apache2]"
147 execute "#{directory}/taginfo/tagstats/Makefile" do
150 cwd "#{directory}/taginfo/tagstats"
153 subscribes :run, "apt_package[libprotozero-dev]"
154 subscribes :run, "apt_package[libosmium2-dev]"
155 subscribes :run, "git[#{directory}/taginfo]"
156 notifies :restart, "service[apache2]"
159 execute "#{directory}/taginfo/Gemfile" do
161 command "bundle#{ruby_version} install"
162 cwd "#{directory}/taginfo"
165 subscribes :run, "gem_package[bundler#{ruby_version}]"
166 subscribes :run, "git[#{directory}/taginfo]"
167 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
170 %w[taginfo/web/tmp bin data data/old download sources planet planet/log].each do |dir|
171 directory "#{directory}/#{dir}" do
178 remote_file "#{directory}/planet/planet.pbf" do
179 action :create_if_missing
180 source "https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
186 template "#{directory}/bin/update-planet" do
187 source "update-planet.erb"
191 variables :directory => directory
194 template "#{directory}/bin/update-taginfo" do
195 source "update-taginfo.erb"
199 variables :directory => directory
202 template "#{directory}/bin/update" do
207 variables :name => site_name, :directory => directory
210 passenger_application "#{directory}/taginfo/web/public"
212 ssl_certificate site_name do
213 domains [site_name] + site_aliases
214 notifies :reload, "service[apache2]"
217 apache_site site_name do
218 template "apache.erb"
219 directory "#{directory}/taginfo/web/public"
220 variables :aliases => site_aliases