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