2 # Cookbook Name:: tilecache
5 # Copyright 2011, 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 # http://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 certificate = node[:tilecache][:ssl][:certificate]
23 node.default[:ssl][:certificates] = node[:ssl][:certificates] | [certificate]
26 include_recipe "squid"
27 include_recipe "nginx"
35 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
36 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
38 tilecaches.each do |cache|
39 cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
40 firewall_rule "accept-squid" do
43 source "net:#{address}"
49 firewall_rule "accept-squid-icp" do
52 source "net:#{address}"
58 firewall_rule "accept-squid-icp-reply" do
70 squid_fragment "tilecache" do
71 template "squid.conf.erb"
72 variables :caches => tilecaches, :renders => tilerenders
75 template "/etc/logrotate.d/squid" do
76 source "logrotate.squid.erb"
82 nginx_site "default" do
86 resolvers = node[:networking][:nameservers].map do |resolver|
87 IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : resolver
90 nginx_site "tile-ssl" do
91 template "nginx_tile_ssl.conf.erb"
92 variables :certificate => certificate, :resolvers => resolvers
95 service "nginx-certificate-restart" do
98 subscribes :restart, "cookbook_file[/etc/ssl/certs/rapidssl.pem]"
99 subscribes :restart, "cookbook_file[/etc/ssl/certs/#{certificate}.pem]"
100 subscribes :restart, "file[/etc/ssl/private/#{certificate}.key]"
103 tilerenders.each do |render|
104 munin_plugin "ping_#{render[:fqdn]}" do
106 conf "munin.ping.erb"
107 conf_variables :host => render[:fqdn]