]> git.openstreetmap.org Git - chef.git/blob - cookbooks/taginfo/recipes/default.rb
ea329a57b310d8f014cd1dae1f21f18e47bc8c0e
[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
55   directory directory do
56     owner "taginfo"
57     group "taginfo"
58     mode 0755
59   end
60
61   git "#{directory}/osmium" do
62     action :sync
63     repository "git://github.com/joto/osmium.git"
64     revision "master"
65     user "taginfo"
66     group "taginfo"
67   end
68
69   git "#{directory}/taginfo" do
70     action :sync
71     repository "git://github.com/joto/taginfo.git"
72     revision "master"
73     user "taginfo"
74     group "taginfo"
75   end
76
77   settings = edit_file "#{directory}/taginfo/taginfo-config-example.json" do |line|
78     line.gsub!(/^( *)"cxxflags": ".*",/, "\\1\"cxxflags\": \"-I../../osmium/include\",")
79
80     line
81   end
82
83   file "#{directory}/taginfo-config.json" do
84     owner "taginfo"
85     group "taginfo"
86     mode 0644
87     content settings
88   end
89
90   execute "#{directory}/taginfo/tagstats/Makefile" do
91     action :nothing
92     command "make"
93     cwd "#{directory}/taginfo/tagstats"
94     user "taginfo"
95     group "taginfo"
96     subscribes :run, "git[#{directory}/osmium]"
97     subscribes :run, "git[#{directory}/taginfo]"
98     notifies :restart, "service[apache2]"
99   end
100
101   directory "#{directory}/data" do
102     owner "taginfo"
103     group "taginfo"
104     mode 0755
105   end
106
107   apache_site name do
108     template "apache.erb"
109     directory "#{directory}/taginfo/web/public"
110   end
111 end