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