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 "git://github.com/taginfo/taginfo.git"
104 revision "osmorg-taginfo-live"
109 settings = Chef::DelayedEvaluator.new do
110 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
112 settings["instance"]["url"] = "https://#{site_name}/"
113 settings["instance"]["description"] = description
114 settings["instance"]["about"] = about
115 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
116 settings["instance"]["contact"] = contact
117 settings["instance"]["access_control_allow_origin"] = ""
118 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
119 settings["opensearch"]["shortname"] = "Taginfo"
120 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
121 settings["sources"]["download"] = ""
122 settings["sources"]["create"] = "db languages projects wiki"
123 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.pbf"
124 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
125 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
127 JSON.pretty_generate(settings)
130 file "#{directory}/taginfo-config.json" do
135 notifies :restart, "service[apache2]"
138 execute "#{directory}/taginfo/tagstats/Makefile" do
141 cwd "#{directory}/taginfo/tagstats"
144 subscribes :run, "apt_package[libprotozero-dev]"
145 subscribes :run, "apt_package[libosmium2-dev]"
146 subscribes :run, "git[#{directory}/taginfo]"
147 notifies :restart, "service[apache2]"
150 execute "#{directory}/taginfo/Gemfile" do
152 command "bundle#{ruby_version} install"
153 cwd "#{directory}/taginfo"
156 subscribes :run, "gem_package[bundler#{ruby_version}]"
157 subscribes :run, "git[#{directory}/taginfo]"
158 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
161 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
162 directory "#{directory}/#{dir}" do
169 template "#{directory}/bin/update" do
174 variables :name => site_name, :directory => directory
177 passenger_application "#{directory}/taginfo/web/public" do
181 ssl_certificate site_name do
182 domains [site_name] + site_aliases
183 notifies :reload, "service[apache2]"
186 apache_site site_name do
187 template "apache.erb"
188 directory "#{directory}/taginfo/web/public"
189 variables :aliases => site_aliases
193 template "/usr/local/bin/taginfo-update" do
194 source "taginfo-update.erb"
198 variables :sites => node[:taginfo][:sites]