]> git.openstreetmap.org Git - chef.git/blob - cookbooks/imagery/resources/layer.rb
Imagery - Disable layer notify to nginx
[chef.git] / cookbooks / imagery / resources / layer.rb
1 #
2 # Cookbook Name:: imagery
3 # Resource:: imagery_layer
4 #
5 # Copyright 2016, OpenStreetMap Foundation
6 #
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
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 default_action :create
21
22 property :name, String
23 property :site, String, :required => true
24 property :source, String, :required => true
25 property :text, String
26 property :copyright, String, :default => "Copyright"
27 property :projection, String, :default => "EPSG:3857"
28 property :palette, String
29 property :extent, String
30 property :background_colour, String
31 property :resample, String, :default => "average"
32 property :imagemode, String
33 property :extension, String,
34          :is => %w(png png8 jpeg),
35          :default => "png"
36 property :max_zoom, Fixnum, :default => 23
37
38 action :create do
39   template "/srv/imagery/mapserver/layer-#{name}.map" do
40     cookbook "imagery"
41     source "mapserver.map.erb"
42     owner "root"
43     group "root"
44     mode 0644
45     variables new_resource.to_hash
46   end
47
48   template "/etc/init/mapserv-fgi-layer-#{name}.conf" do
49     cookbook "imagery"
50     source "mapserv_fcgi.conf.erb"
51     owner "root"
52     group "root"
53     mode 0644
54     variables new_resource.to_hash
55   end
56
57   service "mapserv-fgi-layer-#{name}.conf" do
58     provider Chef::Provider::Service::Upstart
59     action [:enable, :start]
60     supports :status => true, :restart => true, :reload => false
61     subscribes :restart, "template[/srv/imagery/mapserver/layer-#{name}.map]"
62     subscribes :restart, "template[/etc/init/mapserv-fgi-layer-#{name}.conf]"
63   end
64
65   directory "/srv/imagery/nginx/#{site}" do
66     owner "root"
67     group "root"
68     mode 0755
69     recursive true
70   end
71
72   template "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do
73     cookbook "imagery"
74     source "nginx_imagery_layer_fragment.conf.erb"
75     owner "root"
76     group "root"
77     mode 0644
78     variables new_resource.to_hash
79     # FIXME notifies :reload, "service[nginx]", :delayed
80   end
81 end
82
83 action :delete do
84   service "mapserv-fgi-layer-#{name}.conf" do
85     provider Chef::Provider::Service::Upstart
86     action [:stop, :disable]
87     supports :status => true, :restart => true, :reload => false
88   end
89
90   file "/srv/imagery/mapserver/layer-#{name}.map" do
91     action :delete
92   end
93
94   file "/etc/init/mapserv-fgi-layer-#{name}.conf" do
95     action :delete
96   end
97
98   file "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do
99     action :delete
100     # FIXME notifies :reload, "service[nginx]", :delayed
101   end
102 end