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 # https://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.
23 include_recipe "squid"
24 include_recipe "nginx"
35 # oathtool for QoS token
38 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
39 tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] }
41 web_passwords = data_bag_item("web", "passwords")
43 tilecaches.each do |cache|
44 cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address|
45 firewall_rule "accept-squid" do
48 source "net:#{address}"
54 firewall_rule "accept-squid-icp" do
57 source "net:#{address}"
63 firewall_rule "accept-squid-icp-reply" do
75 squid_fragment "tilecache" do
76 template "squid.conf.erb"
77 variables :caches => tilecaches, :renders => tilerenders
80 template "/etc/logrotate.d/squid" do
81 source "logrotate.squid.erb"
87 nginx_site "default" do
91 template "/usr/local/bin/nginx_generate_tilecache_qos_map" do
92 source "nginx_generate_tilecache_qos_map.erb"
96 variables :totp_key => web_passwords["totp_key"]
99 template "/etc/cron.d/tilecache" do
106 execute "execute_nginx_generate_tilecache_qos_map" do
107 command "/usr/local/bin/nginx_generate_tilecache_qos_map"
108 creates "/etc/nginx/conf.d/tile_qos_rates.map"
112 ssl_certificate "tile.openstreetmap.org" do
113 domains ["tile.openstreetmap.org",
114 "a.tile.openstreetmap.org",
115 "b.tile.openstreetmap.org",
116 "c.tile.openstreetmap.org",
121 notifies :restart, "service[nginx]"
125 template "nginx_tile.conf.erb"
126 variables :caches => tilecaches
129 template "/etc/logrotate.d/nginx" do
130 source "logrotate.nginx.erb"
136 tilerenders.each do |render|
137 munin_plugin "ping_#{render[:fqdn]}" do
139 conf "munin.ping.erb"
140 conf_variables :host => render[:fqdn]