]> git.openstreetmap.org Git - chef.git/blob - cookbooks/serverinfo/recipes/default.rb
Merge remote-tracking branch 'tigerfell/pr257'
[chef.git] / cookbooks / serverinfo / recipes / default.rb
1 #
2 # Cookbook:: serverinfo
3 # Recipe:: default
4 #
5 # Copyright:: 2015, 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   gcc
26   g++
27   make
28   libssl-dev
29   zlib1g-dev
30   pkg-config
31 ]
32
33 git "/srv/hardware.openstreetmap.org" do
34   action :sync
35   repository "https://github.com/osmfoundation/osmf-server-info.git"
36   depth 1
37   user "root"
38   group "root"
39   notifies :run, "bundle_install[/srv/hardware.openstreetmap.org]"
40 end
41
42 nodes = { :rows => search(:node, "*:*") }
43 roles = { :rows => search(:role, "*:*") }
44
45 file "/srv/hardware.openstreetmap.org/_data/nodes.json" do
46   content nodes.to_json
47   mode "644"
48   owner "root"
49   group "root"
50   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
51 end
52
53 file "/srv/hardware.openstreetmap.org/_data/roles.json" do
54   content roles.to_json
55   mode "644"
56   owner "root"
57   group "root"
58   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
59 end
60
61 directory "/srv/hardware.openstreetmap.org/_site" do
62   mode "755"
63   owner "nobody"
64   group "nogroup"
65 end
66
67 # Workaround https://github.com/jekyll/jekyll/issues/7804
68 # by creating a .jekyll-cache folder
69 directory "/srv/hardware.openstreetmap.org/.jekyll-cache" do
70   mode "755"
71   owner "nobody"
72   group "nogroup"
73 end
74
75 bundle_install "/srv/hardware.openstreetmap.org" do
76   action :nothing
77   options "--deployment"
78   user "root"
79   group "root"
80   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
81 end
82
83 bundle_exec "/srv/hardware.openstreetmap.org" do
84   action :nothing
85   command "jekyll build --trace --baseurl=https://hardware.openstreetmap.org"
86   user "nobody"
87   group "nogroup"
88 end
89
90 ssl_certificate "hardware.openstreetmap.org" do
91   domains ["hardware.openstreetmap.org", "hardware.osm.org"]
92   notifies :reload, "service[apache2]"
93 end
94
95 apache_site "hardware.openstreetmap.org" do
96   template "apache.erb"
97   directory "/srv/hardware.openstreetmap.org/_site"
98   variables :aliases => ["hardware.osm.org"]
99 end