2 # Cookbook Name:: imagery
3 # Resource:: imagery_layer
5 # Copyright 2016, 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.
22 default_action :create
24 property :layer, String, :name_property => true
25 property :site, String, :required => true
26 property :source, String, :required => true
27 property :root_layer, [TrueClass, FalseClass], :default => false
28 property :title, String
29 property :copyright, String, :default => "Copyright"
30 property :projection, String, :default => "EPSG:3857"
31 property :palette, String
32 property :extent, String
33 property :background_colour, String
34 property :resample, String, :default => "average"
35 property :imagemode, String
36 property :extension, String, :default => "png"
37 property :max_zoom, Integer, :default => 18
38 property :url_aliases, [String, Array], :default => []
39 property :revision, Integer, :default => 0
40 property :overlay, [TrueClass, FalseClass], :default => false
41 property :default_layer, [TrueClass, FalseClass], :default => false
44 file "/srv/imagery/layers/#{new_resource.site}/#{new_resource.layer}.yml" do
48 content YAML.dump(:name => new_resource.layer,
49 :title => new_resource.title || new_resource.layer,
50 :url => "//{s}.#{new_resource.site}/layer/#{new_resource.layer}/{z}/{x}/{y}.png",
51 :attribution => new_resource.copyright,
52 :default => new_resource.default_layer,
53 :maxZoom => new_resource.max_zoom,
54 :overlay => new_resource.overlay)
57 template "/srv/imagery/mapserver/layer-#{new_resource.layer}.map" do
59 source "mapserver.map.erb"
63 variables new_resource.to_hash
64 notifies :restart, "service[mapserv-fcgi-#{new_resource.site}]"
67 # Disable legacy service
68 service "mapserv-fcgi-#{new_resource.layer}" do
69 action [:stop, :disable]
72 # Remove legacy service
73 systemd_service "mapserv-fcgi-#{new_resource.layer}" do
77 directory "/srv/imagery/nginx/#{new_resource.site}" do
84 template "/srv/imagery/nginx/#{new_resource.site}/layer-#{new_resource.layer}.conf" do
86 source "nginx_imagery_layer_fragment.conf.erb"
90 variables new_resource.to_hash
95 file "/srv/imagery/layers/#{new_resource.site}/#{new_resource.layer}.yml" do
99 service "mapserv-fcgi-layer-#{new_resource.layer}" do
100 action [:stop, :disable]
103 file "/srv/imagery/mapserver/layer-#{new_resource.layer}.map" do
107 systemd_service "mapserv-fcgi-#{new_resource.layer}" do
111 file "/srv/imagery/nginx/#{new_resource.site}/layer-#{new_resource.layer}.conf" do
117 notifies :create, "imagery_site[#{site}]"
118 notifies :reload, "service[nginx]"