]> git.openstreetmap.org Git - chef.git/blob - cookbooks/gps-tile/recipes/default.rb
42b3f8a288e749b1cc17083629bbb77cc207bd52
[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 "git://github.com/ericfischer/gpx-import.git"
47   revision "live"
48   user "gpstile"
49   group "gpstile"
50 end
51
52 execute "/srv/gps-tile.openstreetmap.org/import/src/Makefile" do
53   action :nothing
54   command "make DB=none LDFLAGS=-lm"
55   cwd "/srv/gps-tile.openstreetmap.org/import/src"
56   user "gpstile"
57   group "gpstile"
58   subscribes :run, "git[/srv/gps-tile.openstreetmap.org/import]"
59 end
60
61 git "/srv/gps-tile.openstreetmap.org/datamaps" do
62   action :sync
63   repository "git://github.com/ericfischer/datamaps.git"
64   revision "live"
65   user "gpstile"
66   group "gpstile"
67 end
68
69 execute "/srv/gps-tile.openstreetmap.org/datamaps/Makefile" do
70   action :nothing
71   command "make"
72   cwd "/srv/gps-tile.openstreetmap.org/datamaps"
73   user "gpstile"
74   group "gpstile"
75   subscribes :run, "git[/srv/gps-tile.openstreetmap.org/datamaps]"
76 end
77
78 git "/srv/gps-tile.openstreetmap.org/updater" do
79   action :sync
80   repository "git://github.com/ericfischer/gpx-updater.git"
81   revision "live"
82   user "gpstile"
83   group "gpstile"
84 end
85
86 systemd_service "gps-update" do
87   description "GPS tile update daemon"
88   after ["network.target", "memcached.service"]
89   wants ["memcached.service"]
90   user "gpstile"
91   working_directory "/srv/gps-tile.openstreetmap.org"
92   exec_start "/srv/gps-tile.openstreetmap.org/updater/update"
93   private_tmp true
94   private_devices true
95   protect_system "full"
96   protect_home true
97   no_new_privileges true
98   restart "on-failure"
99 end
100
101 service "gps-update" do
102   action [:enable, :start]
103   subscribes :restart, "git[/srv/gps-tile.openstreetmap.org/updater]"
104   subscribes :restart, "systemd_service[gps-update]"
105 end
106
107 remote_directory "/srv/gps-tile.openstreetmap.org/html" do
108   source "html"
109   owner "gpstile"
110   group "gpstile"
111   mode 0o755
112   files_owner "gpstile"
113   files_group "gpstile"
114   files_mode 0o644
115 end
116
117 apache_module "headers"
118 apache_module "rewrite"
119
120 ssl_certificate "gps-tile.openstreetmap.org" do
121   domains ["gps-tile.openstreetmap.org",
122            "a.gps-tile.openstreetmap.org",
123            "b.gps-tile.openstreetmap.org",
124            "c.gps-tile.openstreetmap.org",
125            "gps.tile.openstreetmap.org",
126            "gps-a.tile.openstreetmap.org",
127            "gps-b.tile.openstreetmap.org",
128            "gps-c.tile.openstreetmap.org"]
129   notifies :reload, "service[apache2]"
130 end
131
132 apache_site "gps-tile.openstreetmap.org" do
133   template "apache.erb"
134 end