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"
36 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
37 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
39 tilecaches.each do |cache|
40 cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
41 firewall_rule "accept-squid" do
44 source "net:#{address}"
50 firewall_rule "accept-squid-icp" do
53 source "net:#{address}"
59 firewall_rule "accept-squid-icp-reply" do
71 squid_fragment "tilecache" do
72 template "squid.conf.erb"
73 variables :caches => tilecaches, :renders => tilerenders
76 template "/etc/logrotate.d/squid" do
77 source "logrotate.squid.erb"
83 nginx_site "default" do
87 resolvers = node[:networking][:nameservers].map do |resolver|
88 IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : resolver
91 nginx_site "tile-ssl" do
92 template "nginx_tile_ssl.conf.erb"
93 variables :certificate => certificate, :resolvers => resolvers, :caches => tilecaches
96 service "nginx-certificate-restart" do
99 subscribes :restart, "cookbook_file[/etc/ssl/certs/rapidssl.pem]"
100 subscribes :restart, "cookbook_file[/etc/ssl/certs/#{certificate}.pem]"
101 subscribes :restart, "file[/etc/ssl/private/#{certificate}.key]"
104 tilerenders.each do |render|
105 munin_plugin "ping_#{render[:fqdn]}" do
107 conf "munin.ping.erb"
108 conf_variables :host => render[:fqdn]