From 2c13e97fd4d53a098147c6c6a975977534e02e2c Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Mon, 2 Jan 2017 20:27:51 +0000 Subject: [PATCH] tilecache: chef code for token support --- cookbooks/tilecache/recipes/default.rb | 26 +++++++++++++++++++ .../tilecache/templates/default/cron.erb | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 cookbooks/tilecache/templates/default/cron.erb diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index b97ce12c8..87b27bc01 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -33,9 +33,14 @@ end package "xz-utils" package "openssl" +# oathtool for QoS token +package "oathtool" + tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] } tilerenders = search(:node, "roles:tile").sort_by { |n| n[:hostname] } +tilecache_tokens = data_bag_item("tilecache", "tokens") + tilecaches.each do |cache| cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address| firewall_rule "accept-squid" do @@ -93,6 +98,27 @@ nginx_site "tile-ssl" do variables :certificate => certificate, :resolvers => resolvers, :caches => tilecaches end +template "/usr/local/bin/nginx_generate_tilecache_qos_map" do + source "nginx_generate_tilecache_qos_map.erb" + owner "root" + group "root" + mode 0o750 + variables tokens: => tilecache_tokens +end + +template "/etc/cron.d/tilecache" do + source "cron.erb" + owner "root" + group "root" + mode 0o644 +end + +execute 'execute_nginx_generate_tilecache_qos_map' do + command '/usr/local/bin/nginx_generate_tilecache_qos_map' + creates '/etc/nginx/conf.d/tile_qos_rates.map' + action :run +end + service "nginx-certificate-restart" do service_name "nginx" action :nothing diff --git a/cookbooks/tilecache/templates/default/cron.erb b/cookbooks/tilecache/templates/default/cron.erb new file mode 100644 index 000000000..32fb06762 --- /dev/null +++ b/cookbooks/tilecache/templates/default/cron.erb @@ -0,0 +1,3 @@ +# DO NOT EDIT - This file is being maintained by Chef + +0 * * * * root /usr/local/bin/nginx_generate_tilecache_qos_map -- 2.43.2