]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tilecache/recipes/default.rb
687478e581df41c71ad7fa191fc3c4057a1819a7
[chef.git] / cookbooks / tilecache / recipes / default.rb
1 #
2 # Cookbook Name:: tilecache
3 # Recipe:: default
4 #
5 # Copyright 2011, 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 node.default[:ssl][:certificates] = node[:ssl][:certificates] | [ "tile.openstreetmap" ]
21
22 include_recipe "ssl"
23 include_recipe "squid"
24 include_recipe "nginx"
25
26 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
27 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
28
29 tilecaches.each do |cache|
30   cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
31     firewall_rule "accept-squid" do
32       action :accept
33       family "inet"
34       source "net:#{address}"
35       dest "fw"
36       proto "tcp:syn"
37       dest_ports "3128"
38       source_ports "1024:"
39     end
40     firewall_rule "accept-squid-icp" do
41       action :accept
42       family "inet"
43       source "net:#{address}"
44       dest "fw"
45       proto "udp"
46       dest_ports "3130"
47       source_ports "1024:"
48     end
49   end
50 end
51
52 squid_fragment "tilecache" do
53   template "squid.conf.erb"
54   variables :caches => tilecaches, :renders => tilerenders
55 end
56
57 template "/etc/logrotate.d/squid" do
58   source "logrotate.squid.erb"
59   owner "root"
60   group "root"
61   mode 0644
62 end
63
64 nginx_site "default" do
65   action :delete
66 end
67
68 nginx_site "tile-ssl" do
69   source "nginx_tile_ssl.conf.erb"
70 end
71