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"
31 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
32 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
34 tilecaches.each do |cache|
35 cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
36 firewall_rule "accept-squid" do
39 source "net:#{address}"
45 firewall_rule "accept-squid-icp" do
48 source "net:#{address}"
54 firewall_rule "accept-squid-icp-reply" do
66 squid_fragment "tilecache" do
67 template "squid.conf.erb"
68 variables :caches => tilecaches, :renders => tilerenders
71 template "/etc/logrotate.d/squid" do
72 source "logrotate.squid.erb"
78 nginx_site "default" do
82 resolvers = node[:networking][:nameservers].map do |resolver|
83 IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : "#{resolver}"
86 nginx_site "tile-ssl" do
87 template "nginx_tile_ssl.conf.erb"
88 variables :certificate => certificate, :resolvers => resolvers
91 service "nginx-certificate-restart" do
94 subscribes :restart, "cookbook_file[/etc/ssl/certs/rapidssl.pem]"
95 subscribes :restart, "cookbook_file[/etc/ssl/certs/#{certificate}.pem]"
96 subscribes :restart, "file[/etc/ssl/private/#{certificate}.key]"
99 tilerenders.each do |render|
100 munin_plugin "ping_#{render[:fqdn]}" do
102 conf "munin.ping.erb"
103 conf_variables :host => render[:fqdn]