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 directory "/var/log/taginfo" do
71 template "/etc/sudoers.d/taginfo" do
78 node[:taginfo][:sites].each do |site|
79 site_name = site[:name]
80 site_aliases = Array(site[:aliases])
81 directory = site[:directory] || "/srv/#{site_name}"
82 description = site[:description]
85 contact = site[:contact]
87 directory "/var/log/taginfo/#{site_name}" do
93 directory directory do
99 git "#{directory}/taginfo" do
101 repository "git://github.com/taginfo/taginfo.git"
102 revision "osmorg-taginfo-live"
107 settings = Chef::DelayedEvaluator.new do
108 settings = JSON.parse(IO.read("#{directory}/taginfo/taginfo-config-example.json"))
110 settings["instance"]["url"] = "https://#{site_name}/"
111 settings["instance"]["description"] = description
112 settings["instance"]["about"] = about
113 settings["instance"]["icon"] = "/img/logo/#{icon}.png"
114 settings["instance"]["contact"] = contact
115 settings["instance"]["access_control_allow_origin"] = ""
116 settings["logging"]["directory"] = "/var/log/taginfo/#{site_name}"
117 settings["opensearch"]["shortname"] = "Taginfo"
118 settings["opensearch"]["contact"] = "webmaster@openstreetmap.org"
119 settings["sources"]["download"] = ""
120 settings["sources"]["create"] = "db languages projects wiki"
121 settings["sources"]["db"]["planetfile"] = "/var/lib/planet/planet.pbf"
122 settings["sources"]["db"]["bindir"] = "#{directory}/taginfo/tagstats"
123 settings["tagstats"]["geodistribution"] = "DenseMmapArray"
125 JSON.pretty_generate(settings)
128 file "#{directory}/taginfo-config.json" do
133 notifies :restart, "service[apache2]"
136 execute "#{directory}/taginfo/tagstats/Makefile" do
139 cwd "#{directory}/taginfo/tagstats"
142 subscribes :run, "apt_package[libprotozero-dev]"
143 subscribes :run, "apt_package[libosmium2-dev]"
144 subscribes :run, "git[#{directory}/taginfo]"
145 notifies :restart, "service[apache2]"
148 execute "#{directory}/taginfo/Gemfile" do
150 command "bundle#{ruby_version} install"
151 cwd "#{directory}/taginfo"
154 subscribes :run, "gem_package[bundler#{ruby_version}]"
155 subscribes :run, "git[#{directory}/taginfo]"
156 notifies :restart, "passenger_application[#{directory}/taginfo/web/public]"
159 %w[taginfo/web/tmp bin data data/old download sources].each do |dir|
160 directory "#{directory}/#{dir}" do
167 template "#{directory}/bin/update" do
172 variables :name => site_name, :directory => directory
175 passenger_application "#{directory}/taginfo/web/public"
177 ssl_certificate site_name do
178 domains [site_name] + site_aliases
179 notifies :reload, "service[apache2]"
182 apache_site site_name do
183 template "apache.erb"
184 directory "#{directory}/taginfo/web/public"
185 variables :aliases => site_aliases
189 template "/usr/local/bin/taginfo-update" do
190 source "taginfo-update.erb"
194 variables :sites => node[:taginfo][:sites]