]> git.openstreetmap.org Git - chef.git/blob - cookbooks/gps-tile/recipes/default.rb
b960143e7dd605319f23d8a58965766383329505
[chef.git] / cookbooks / gps-tile / recipes / default.rb
1 #
2 # Cookbook:: gps-tile
3 # Recipe:: default
4 #
5 # Copyright:: 2013, 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 #     https://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 include_recipe "accounts"
21 include_recipe "apache"
22 include_recipe "git"
23 include_recipe "memcached"
24
25 package %w[
26   make
27   build-essential
28   pkg-config
29   zlib1g-dev
30   libbz2-dev
31   libarchive-dev
32   libexpat1-dev
33   libpng-dev
34   pngquant
35   libcache-memcached-perl
36 ]
37
38 directory "/srv/gps-tile.openstreetmap.org" do
39   owner "gpstile"
40   group "gpstile"
41   mode 0o755
42 end
43
44 git "/srv/gps-tile.openstreetmap.org/import" do
45   action :sync
46   repository "https://github.com/ericfischer/gpx-import.git"
47   revision "live"
48   depth 1
49   user "gpstile"
50   group "gpstile"
51 end
52
53 execute "/srv/gps-tile.openstreetmap.org/import/src/Makefile" do
54   action :nothing
55   command "make DB=none LDFLAGS=-lm"
56   cwd "/srv/gps-tile.openstreetmap.org/import/src"
57   user "gpstile"
58   group "gpstile"
59   subscribes :run, "git[/srv/gps-tile.openstreetmap.org/import]"
60 end
61
62 git "/srv/gps-tile.openstreetmap.org/datamaps" do
63   action :sync
64   repository "https://github.com/ericfischer/datamaps.git"
65   revision "live"
66   depth 1
67   user "gpstile"
68   group "gpstile"
69 end
70
71 execute "/srv/gps-tile.openstreetmap.org/datamaps/Makefile" do
72   action :nothing
73   command "make"
74   cwd "/srv/gps-tile.openstreetmap.org/datamaps"
75   user "gpstile"
76   group "gpstile"
77   subscribes :run, "git[/srv/gps-tile.openstreetmap.org/datamaps]"
78 end
79
80 git "/srv/gps-tile.openstreetmap.org/updater" do
81   action :sync
82   repository "https://github.com/ericfischer/gpx-updater.git"
83   revision "live"
84   depth 1
85   user "gpstile"
86   group "gpstile"
87 end
88
89 systemd_service "gps-update" do
90   description "GPS tile update daemon"
91   after ["network.target", "memcached.service"]
92   wants ["memcached.service"]
93   user "gpstile"
94   working_directory "/srv/gps-tile.openstreetmap.org"
95   exec_start "/srv/gps-tile.openstreetmap.org/updater/update"
96   private_tmp true
97   private_devices true
98   protect_system "full"
99   protect_home true
100   no_new_privileges true
101   restart "on-failure"
102 end
103
104 service "gps-update" do
105   action [:enable, :start]
106   subscribes :restart, "git[/srv/gps-tile.openstreetmap.org/updater]"
107   subscribes :restart, "systemd_service[gps-update]"
108 end
109
110 remote_directory "/srv/gps-tile.openstreetmap.org/html" do
111   source "html"
112   owner "gpstile"
113   group "gpstile"
114   mode 0o755
115   files_owner "gpstile"
116   files_group "gpstile"
117   files_mode 0o644
118 end
119
120 apache_module "headers"
121 apache_module "rewrite"
122
123 ssl_certificate "gps-tile.openstreetmap.org" do
124   domains ["gps-tile.openstreetmap.org",
125            "a.gps-tile.openstreetmap.org",
126            "b.gps-tile.openstreetmap.org",
127            "c.gps-tile.openstreetmap.org",
128            "gps.tile.openstreetmap.org",
129            "gps-a.tile.openstreetmap.org",
130            "gps-b.tile.openstreetmap.org",
131            "gps-c.tile.openstreetmap.org"]
132   notifies :reload, "service[apache2]"
133 end
134
135 apache_site "gps-tile.openstreetmap.org" do
136   template "apache.erb"
137 end