]> git.openstreetmap.org Git - chef.git/blob - cookbooks/blogs/recipes/default.rb
Switch orm to carto 6.0.0
[chef.git] / cookbooks / blogs / recipes / default.rb
1 #
2 # Cookbook:: blogs
3 # Recipe:: default
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 #     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 "apache"
21 include_recipe "git"
22 include_recipe "ruby"
23
24 package %w[
25   make
26   gcc
27   g++
28   libsqlite3-dev
29   sqlite3
30 ]
31
32 group "blogs" do
33   gid 525
34   append true
35 end
36
37 user "blogs" do
38   uid 525
39   gid 525
40   comment "blogs.openstreetmap.org"
41   home "/srv/blogs.openstreetmap.org"
42   shell "/usr/sbin/nologin"
43   manage_home false
44 end
45
46 directory "/srv/blogs.openstreetmap.org" do
47   owner "blogs"
48   group "blogs"
49   mode "755"
50 end
51
52 git "/srv/blogs.openstreetmap.org" do
53   action :sync
54   repository "https://github.com/gravitystorm/blogs.osm.org.git"
55   depth 1
56   user "blogs"
57   group "blogs"
58 end
59
60 bundle_config "/srv/blogs.openstreetmap.org" do
61   action :nothing
62   user "blogs"
63   group "blogs"
64   settings "deployment" => "true",
65            "without" => "development:test",
66            "build.sqlite3" => "--enable-system-libraries"
67   subscribes :create, "git[/srv/blogs.openstreetmap.org]", :immediately
68 end
69
70 bundle_install "/srv/blogs.openstreetmap.org" do
71   action :nothing
72   user "blogs"
73   group "blogs"
74   subscribes :run, "git[/srv/blogs.openstreetmap.org]", :immediately
75 end
76
77 bundle_exec "/srv/blogs.openstreetmap.org" do
78   action :nothing
79   command "pluto build -t osm -o build"
80   user "blogs"
81   group "blogs"
82   subscribes :run, "git[/srv/blogs.openstreetmap.org]", :immediately
83   retries 2 # May fail on first run due to faulty blogs
84 end
85
86 ssl_certificate "blogs.openstreetmap.org" do
87   domains ["blogs.openstreetmap.org", "blogs.osm.org"]
88   notifies :reload, "service[apache2]"
89 end
90
91 apache_site "blogs.openstreetmap.org" do
92   template "apache.erb"
93   directory "/srv/blogs.openstreetmap.org/build"
94   variables :aliases => ["blogs.osm.org"]
95 end
96
97 template "/usr/local/bin/blogs-update" do
98   source "blogs-update.erb"
99   owner "root"
100   group "root"
101   mode "0755"
102 end
103
104 systemd_service "blogs-update" do
105   description "Update blog aggregator"
106   exec_start "/usr/local/bin/blogs-update"
107   user "blogs"
108   sandbox :enable_network => true
109   read_write_paths "/srv/blogs.openstreetmap.org"
110 end
111
112 systemd_timer "blogs-update" do
113   description "Update blog aggregator"
114   on_boot_sec "15m"
115   on_unit_inactive_sec "30m"
116 end
117
118 service "blogs-update.timer" do
119   action [:enable, :start]
120 end
121
122 template "/etc/cron.daily/blogs-backup" do
123   source "backup.cron.erb"
124   owner "root"
125   group "root"
126   mode "0755"
127 end