]> git.openstreetmap.org Git - chef.git/blob - cookbooks/serverinfo/recipes/default.rb
Add test for serverinfo cookbook
[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   user "root"
39   group "root"
40   notifies :run, "execute[/srv/hardware.openstreetmap.org/Gemfile]"
41 end
42
43 nodes = { :rows => search(:node, "*:*") }
44 roles = { :rows => search(:role, "*:*") }
45
46 file "/srv/hardware.openstreetmap.org/_data/nodes.json" do
47   content nodes.to_json
48   mode 0o644
49   owner "root"
50   group "root"
51   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
52 end
53
54 file "/srv/hardware.openstreetmap.org/_data/roles.json" do
55   content roles.to_json
56   mode 0o644
57   owner "root"
58   group "root"
59   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
60 end
61
62 directory "/srv/hardware.openstreetmap.org/_site" do
63   mode 0o755
64   owner "nobody"
65   group "nogroup"
66 end
67
68 # Workaround https://github.com/jekyll/jekyll/issues/7804
69 # by creating a .jekyll-cache folder
70 directory "/srv/hardware.openstreetmap.org/.jekyll-cache" do
71   mode 0o755
72   owner "nobody"
73   group "nogroup"
74 end
75
76 execute "/srv/hardware.openstreetmap.org/Gemfile" do
77   action :nothing
78   command "bundle install --deployment"
79   cwd "/srv/hardware.openstreetmap.org"
80   user "root"
81   group "root"
82   notifies :run, "execute[/srv/hardware.openstreetmap.org]"
83 end
84
85 execute "/srv/hardware.openstreetmap.org" do
86   action :nothing
87   command "bundle exec jekyll build --trace --baseurl=https://hardware.openstreetmap.org"
88   cwd "/srv/hardware.openstreetmap.org"
89   user "nobody"
90   group "nogroup"
91 end
92
93 ssl_certificate "hardware.openstreetmap.org" do
94   domains ["hardware.openstreetmap.org", "hardware.osm.org"]
95   notifies :reload, "service[apache2]"
96 end
97
98 apache_site "hardware.openstreetmap.org" do
99   template "apache.erb"
100   directory "/srv/hardware.openstreetmap.org/_site"
101   variables :aliases => ["hardware.osm.org"]
102 end