]> git.openstreetmap.org Git - chef.git/blob - cookbooks/serverinfo/recipes/default.rb
Git only checkout 1 deep
[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
23 package %w[
24   ruby
25   ruby-dev
26   libssl-dev
27   zlib1g-dev
28   pkg-config
29 ]
30
31 gem_package "bundler" do
32   version "1.17.3"
33 end
34
35 git "/srv/hardware.openstreetmap.org" do
36   action :sync
37   repository "git://github.com/gravitystorm/osmf-server-info.git"
38   depth 1
39   user "root"
40   group "root"
41   notifies :run, "execute[/srv/hardware.openstreetmap.org/Gemfile]"
42 end
43
44 nodes = { :rows => search(:node, "*:*") }
45 roles = { :rows => search(:role, "*:*") }
46
47 file "/srv/hardware.openstreetmap.org/_data/nodes.json" do
48   content nodes.to_json
49   mode 0o644
50   owner "root"
51   group "root"
52   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
53 end
54
55 file "/srv/hardware.openstreetmap.org/_data/roles.json" do
56   content roles.to_json
57   mode 0o644
58   owner "root"
59   group "root"
60   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
61 end
62
63 directory "/srv/hardware.openstreetmap.org/_site" do
64   mode 0o755
65   owner "nobody"
66   group "nogroup"
67 end
68
69 # Workaround https://github.com/jekyll/jekyll/issues/7804
70 # by creating a .jekyll-cache folder
71 directory "/srv/hardware.openstreetmap.org/.jekyll-cache" do
72   mode 0o755
73   owner "nobody"
74   group "nogroup"
75 end
76
77 execute "/srv/hardware.openstreetmap.org/Gemfile" do
78   action :nothing
79   command "bundle install --deployment"
80   cwd "/srv/hardware.openstreetmap.org"
81   user "root"
82   group "root"
83   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
84 end
85
86 execute "/srv/hardware.openstreetmap.org" do
87   action :nothing
88   command "bundle exec jekyll build --trace --baseurl=https://hardware.openstreetmap.org"
89   cwd "/srv/hardware.openstreetmap.org"
90   user "nobody"
91   group "nogroup"
92 end
93
94 ssl_certificate "hardware.openstreetmap.org" do
95   domains ["hardware.openstreetmap.org", "hardware.osm.org"]
96   notifies :reload, "service[apache2]"
97 end
98
99 apache_site "hardware.openstreetmap.org" do
100   template "apache.erb"
101   directory "/srv/hardware.openstreetmap.org/_site"
102   variables :aliases => ["hardware.osm.org"]
103 end