]> git.openstreetmap.org Git - chef.git/blob - cookbooks/taginfo/recipes/default.rb
More work on taginfo
[chef.git] / cookbooks / taginfo / recipes / default.rb
1 #
2 # Cookbook Name:: taginfo
3 # Recipe:: default
4 #
5 # Copyright 2014, OpenStreetMap Foundation
6 #
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
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 include_recipe "apache::ssl"
21 include_recipe "git"
22
23 package "libsqlite3-dev"
24 package "zlib1g-dev"
25 package "libosmpbf-dev"
26 package "libprotobuf-dev"
27 package "libboost-dev"
28 package "libexpat1-dev"
29 package "libsparsehash-dev"
30 package "libgd2-xpm-dev"
31 package "make"
32 package "g++"
33
34 package "sqlite3"
35
36 package "ruby"
37 package "rubygems"
38 gem_package "json"
39 gem_package "sqlite3"
40 gem_package "sinatra"
41 gem_package "sinatra-r18n"
42 gem_package "rack-contrib"
43
44 apache_module "passenger"
45
46 munin_plugin "passenger_memory"
47 munin_plugin "passenger_processes"
48 munin_plugin "passenger_queues"
49 munin_plugin "passenger_requests"
50
51 node[:taginfo][:sites].each do |site|
52   name = site[:name]
53   directory = site[:directory] || "/srv/#{name}"
54   description = site[:description]
55   icon = site[:icon]
56   contact = site[:contact]
57
58   directory directory do
59     owner "taginfo"
60     group "taginfo"
61     mode 0755
62   end
63
64   git "#{directory}/osmium" do
65     action :sync
66     repository "git://github.com/joto/osmium.git"
67     revision "master"
68     user "taginfo"
69     group "taginfo"
70   end
71
72   git "#{directory}/taginfo" do
73     action :sync
74     repository "git://github.com/joto/taginfo.git"
75     revision "master"
76     user "taginfo"
77     group "taginfo"
78   end
79
80   settings = edit_file "#{directory}/taginfo/taginfo-config-example.json" do |line|
81     line.gsub!(/^( *)"url": ".*",/, "\\1\"url\": \"http://#{name}/\",")
82     line.gsub!(/^( *)"description": ".*Change this text.*,/, "\\1\"description\": \"#{description}\",")
83     line.gsub!(/^( *)"icon": ".*",/, "\\1\"icon\": \"/img/logo/#{icon}.png\",")
84     line.gsub!(/^( *)"contact": "Anonymous",/, "\\1\"contact\": \"#{contact}\",")
85     line.gsub!(/^( *)"shortname": ".*",/, "\\1\"shortname\": \"Taginfo\",")
86     line.gsub!(/^( *)"contact": "somebody@example.com",/, "\\1\"contact\": \"webmaster@openstreetmap.org\",")
87     line.gsub!(/^( *)"cxxflags": ".*",/, "\\1\"cxxflags\": \"-I../../osmium/include\",")
88
89     line
90   end
91
92   file "#{directory}/taginfo-config.json" do
93     owner "taginfo"
94     group "taginfo"
95     mode 0644
96     content settings
97   end
98
99   execute "#{directory}/taginfo/tagstats/Makefile" do
100     action :nothing
101     command "make"
102     cwd "#{directory}/taginfo/tagstats"
103     user "taginfo"
104     group "taginfo"
105     subscribes :run, "git[#{directory}/osmium]"
106     subscribes :run, "git[#{directory}/taginfo]"
107     notifies :restart, "service[apache2]"
108   end
109
110   directory "#{directory}/data" do
111     owner "taginfo"
112     group "taginfo"
113     mode 0755
114   end
115
116   apache_site name do
117     template "apache.erb"
118     directory "#{directory}/taginfo/web/public"
119   end
120 end