]> git.openstreetmap.org Git - chef.git/blob - cookbooks/serverinfo/recipes/default.rb
dulcy: move to postgresql 18
[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 group "serverinfo" do
34   gid 534
35   append true
36 end
37
38 user "serverinfo" do
39   uid 534
40   gid 534
41   comment "hardware.openstreetmap.org"
42   home "/srv/hardware.openstreetmap.org"
43   shell "/usr/sbin/nologin"
44   manage_home false
45 end
46
47 directory "/srv/hardware.openstreetmap.org" do
48   owner "serverinfo"
49   group "serverinfo"
50   mode "755"
51 end
52
53 git "/srv/hardware.openstreetmap.org" do
54   action :sync
55   repository "https://github.com/osmfoundation/osmf-server-info.git"
56   depth 1
57   user "serverinfo"
58   group "serverinfo"
59   notifies :run, "bundle_install[/srv/hardware.openstreetmap.org]"
60 end
61
62 nodes = { :rows => search(:node, "*:*") }
63 roles = { :rows => search(:role, "*:*") }
64
65 file "/srv/hardware.openstreetmap.org/_data/nodes.json" do
66   content nodes.to_json
67   mode "644"
68   owner "serverinfo"
69   group "serverinfo"
70   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
71   sensitive true
72 end
73
74 file "/srv/hardware.openstreetmap.org/_data/roles.json" do
75   content roles.to_json
76   mode "644"
77   owner "serverinfo"
78   group "serverinfo"
79   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
80 end
81
82 bundle_config "/srv/hardware.openstreetmap.org" do
83   action :create
84   user "serverinfo"
85   group "serverinfo"
86   settings "deployment" => "true",
87            "without" => "development:test",
88            "jobs" => node.cpu_cores.to_s
89   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
90 end
91
92 bundle_install "/srv/hardware.openstreetmap.org" do
93   action :nothing
94   user "serverinfo"
95   group "serverinfo"
96   notifies :run, "bundle_exec[/srv/hardware.openstreetmap.org]"
97 end
98
99 bundle_exec "/srv/hardware.openstreetmap.org" do
100   action :nothing
101   command "jekyll build --trace --disable-disk-cache --baseurl=https://hardware.openstreetmap.org"
102   user "serverinfo"
103   group "serverinfo"
104   environment "LANG" => "C.UTF-8"
105 end
106
107 ssl_certificate "hardware.openstreetmap.org" do
108   domains ["hardware.openstreetmap.org", "hardware.osm.org", "hardware.osmfoundation.org"]
109   notifies :reload, "service[apache2]"
110 end
111
112 apache_site "hardware.openstreetmap.org" do
113   template "apache.erb"
114   directory "/srv/hardware.openstreetmap.org/_site"
115   variables :aliases => ["hardware.osm.org", "hardware.osmfoundation.org"]
116 end