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.
 
  20 certificate = node[:tilecache][:ssl][:certificate]
 
  21 node.default[:ssl][:certificates] = node[:ssl][:certificates] | [ certificate ]
 
  24 include_recipe "squid"
 
  25 include_recipe "nginx"
 
  29 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
 
  30 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
 
  32 tilecaches.each do |cache|
 
  33   cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
 
  34     firewall_rule "accept-squid" do
 
  37       source "net:#{address}"
 
  43     firewall_rule "accept-squid-icp" do
 
  46       source "net:#{address}"
 
  52     firewall_rule "accept-squid-icp-reply" do
 
  64 squid_fragment "tilecache" do
 
  65   template "squid.conf.erb"
 
  66   variables :caches => tilecaches, :renders => tilerenders
 
  69 template "/etc/logrotate.d/squid" do
 
  70   source "logrotate.squid.erb"
 
  76 nginx_site "default" do
 
  80 nginx_site "tile-ssl" do
 
  81   template "nginx_tile_ssl.conf.erb"
 
  82   variables :certificate => certificate
 
  85 service "nginx-certificate-restart" do
 
  88   subscribes :restart, "cookbook_file[/etc/ssl/certs/rapidssl.pem]"
 
  89   subscribes :restart, "cookbook_file[/etc/ssl/certs/#{certificate}.pem]"
 
  90   subscribes :restart, "file[/etc/ssl/private/#{certificate}.key]"
 
  93 tilerenders.each do |render|
 
  94   munin_plugin "ping_#{render[:fqdn]}" do
 
  97     conf_variables :host => render[:fqdn]