]> git.openstreetmap.org Git - chef.git/blob - cookbooks/switch2osm/recipes/default.rb
Add test for switch2osm cookbook
[chef.git] / cookbooks / switch2osm / recipes / default.rb
1 #
2 # Cookbook:: switch2osm
3 # Recipe:: default
4 #
5 # Copyright:: 2013, 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 apache_module "expires"
32 apache_module "rewrite"
33
34 gem_package "bundler" do
35   version "1.17.3"
36 end
37
38 git "/srv/switch2osm.org" do
39   action :sync
40   repository "https://github.com/switch2osm/switch2osm.github.io.git"
41   user "root"
42   group "root"
43   notifies :run, "execute[/srv/switch2osm.org/Gemfile]"
44 end
45
46 directory "/srv/switch2osm.org/_site" do
47   mode 0o755
48   owner "nobody"
49   group "nogroup"
50 end
51
52 # Workaround https://github.com/jekyll/jekyll/issues/7804
53 # by creating a .jekyll-cache folder
54 directory "/srv/switch2osm.org/.jekyll-cache" do
55   mode 0o755
56   owner "nobody"
57   group "nogroup"
58 end
59
60 execute "/srv/switch2osm.org/Gemfile" do
61   action :nothing
62   command "bundle install --deployment"
63   cwd "/srv/switch2osm.org"
64   user "root"
65   group "root"
66   notifies :run, "execute[/srv/switch2osm.org]"
67 end
68
69 execute "/srv/switch2osm.org" do
70   action :nothing
71   command "bundle exec jekyll build --trace --config _config.yml,_config_osm.yml"
72   cwd "/srv/switch2osm.org"
73   user "nobody"
74   group "nogroup"
75 end
76
77 ssl_certificate "switch2osm.org" do
78   domains ["switch2osm.org",
79            "www.switch2osm.org", "switch2osm.com", "www.switch2osm.com"]
80   notifies :reload, "service[apache2]"
81 end
82
83 apache_site "switch2osm.org" do
84   template "apache.erb"
85   directory "/srv/switch2osm.org/_site"
86 end