]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tilecache/recipes/default.rb
209a83dc969f3166059e13f000b5303016ddb9e8
[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 package "xz-utils"
27
28 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
29 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
30
31 tilecaches.each do |cache|
32   cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
33     firewall_rule "accept-squid" do
34       action :accept
35       family "inet"
36       source "net:#{address}"
37       dest "fw"
38       proto "tcp:syn"
39       dest_ports "3128"
40       source_ports "1024:"
41     end
42     firewall_rule "accept-squid-icp" do
43       action :accept
44       family "inet"
45       source "net:#{address}"
46       dest "fw"
47       proto "udp"
48       dest_ports "3130"
49       source_ports "1024:"
50     end
51     firewall_rule "accept-squid-icp-reply" do
52       action :accept
53       family "inet"
54       source "fw"
55       dest "net:#{address}"
56       proto "udp"
57       dest_ports "3130"
58       source_ports "1024:"
59     end
60   end
61 end
62
63 squid_fragment "tilecache" do
64   template "squid.conf.erb"
65   variables :caches => tilecaches, :renders => tilerenders
66 end
67
68 template "/etc/logrotate.d/squid" do
69   source "logrotate.squid.erb"
70   owner "root"
71   group "root"
72   mode 0644
73 end
74
75 nginx_site "default" do
76   action [ :delete ]
77 end
78
79 nginx_site "tile-ssl" do
80   template "nginx_tile_ssl.conf.erb"
81 end
82