]> git.openstreetmap.org Git - chef.git/blob - cookbooks/serverinfo/recipes/default.rb
Merge remote-tracking branch 'github/pull/741'
[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 "accounts"
21 include_recipe "apache"
22 include_recipe "git"
23 include_recipe "ruby"
24
25 package %w[
26   gcc
27   g++
28   make
29   libssl-dev
30   zlib1g-dev
31   pkg-config
32 ]
33
34 directory "/srv/hardware.openstreetmap.org" do
35   owner "serverinfo"
36   group "serverinfo"
37   mode "755"
38 end
39
40 git "/srv/hardware.openstreetmap.org" do
41   action :sync
42   repository "https://github.com/osmfoundation/osmf-server-info.git"
43   depth 1
44   user "serverinfo"
45   group "serverinfo"
46   notifies :run, "bundle_install[/srv/hardware.openstreetmap.org]"
47 end
48
49 nodes = { :rows => search(:node, "*:*") }
50 roles = { :rows => search(:role, "*:*") }
51
52 file "/srv/hardware.openstreetmap.org/_data/nodes.json" do
53   content nodes.to_json
54   mode "644"
55   owner "serverinfo"
56   group "serverinfo"
57   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
58 end
59
60 file "/srv/hardware.openstreetmap.org/_data/roles.json" do
61   content roles.to_json
62   mode "644"
63   owner "serverinfo"
64   group "serverinfo"
65   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
66 end
67
68 bundle_config "/srv/hardware.openstreetmap.org" do
69   action :create
70   user "serverinfo"
71   group "serverinfo"
72   settings "deployment" => "true",
73            "without" => "development:test",
74            "jobs" => node.cpu_cores.to_s
75   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
76 end
77
78 bundle_install "/srv/hardware.openstreetmap.org" do
79   action :nothing
80   user "serverinfo"
81   group "serverinfo"
82   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
83 end
84
85 bundle_exec "/srv/hardware.openstreetmap.org" do
86   action :nothing
87   command "jekyll build --trace --disable-disk-cache --baseurl=https://hardware.openstreetmap.org"
88   user "serverinfo"
89   group "serverinfo"
90   environment "LANG" => "C.UTF-8"
91 end
92
93 ssl_certificate "hardware.openstreetmap.org" do
94   domains ["hardware.openstreetmap.org", "hardware.osm.org", "hardware.osmfoundation.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", "hardware.osmfoundation.org"]
102 end