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" do
103 repository "https://github.com/taginfo/taginfo.git"
104 revision "osmorg-taginfo-live"
110 settings = Chef::DelayedEvaluator.new do
111 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
113 settings["instance"]["url"] = "https://#{site_name}/"
114 settings["instance"]["description"] = description
115 settings["instance"]["about"] = about
116 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
117 settings["instance"]["contact"] = contact
118 settings["instance"]["access_control_allow_origin"] = ""
119 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
120 settings["opensearch"]["shortname"] = "Taginfo"
121 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
122 settings["sources"]["download"] = ""
123 settings["sources"]["create"] = "db languages projects wiki"
124 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.pbf"
125 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
126 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
128 JSON.pretty_generate(settings)
131 file "#{directory}/taginfo-config.json" do
136 notifies :restart, "service[apache2]"
139 execute "#{directory}/taginfo/tagstats/Makefile" do
142 cwd "#{directory}/taginfo/tagstats"
145 subscribes :run, "apt_package[libprotozero-dev]"
146 subscribes :run, "apt_package[libosmium2-dev]"
147 subscribes :run, "git[#{directory}/taginfo]"
148 notifies :restart, "service[apache2]"
151 execute "#{directory}/taginfo/Gemfile" do
153 command "bundle#{ruby_version} install"
154 cwd "#{directory}/taginfo"
157 subscribes :run, "gem_package[bundler#{ruby_version}]"
158 subscribes :run, "git[#{directory}/taginfo]"
159 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
162 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
163 directory "#{directory}/#{dir}" do
170 template "#{directory}/bin/update" do
175 variables :name => site_name, :directory => directory
178 passenger_application "#{directory}/taginfo/web/public" do
182 ssl_certificate site_name do
183 domains [site_name] + site_aliases
184 notifies :reload, "service[apache2]"
187 apache_site site_name do
188 template "apache.erb"
189 directory "#{directory}/taginfo/web/public"
190 variables :aliases => site_aliases
194 template "/usr/local/bin/taginfo-update" do
195 source "taginfo-update.erb"
199 variables :sites => node[:taginfo][:sites]