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