]> git.openstreetmap.org Git - chef.git/blob - cookbooks/community/recipes/default.rb
Extend chef discourse/community management
[chef.git] / cookbooks / community / recipes / default.rb
1 #
2 # Cookbook:: community
3 # Recipe:: default
4 #
5 # Copyright:: 2021, 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 "docker"
21 include_recipe "git"
22 include_recipe "ssl"
23 include_recipe "geoipupdate"
24
25 passwords = data_bag_item("community", "passwords")
26 license_keys = data_bag_item("geoipupdate", "license-keys")
27
28 ssl_certificate "community.openstreetmap.org" do
29   domains ["community.openstreetmap.org", "community.osm.org"]
30   notifies :run, "execute[discourse_container_web_only_rebuild]"
31 end
32
33 directory "/srv/community.openstreetmap.org" do
34   owner "root"
35   group "root"
36   mode "755"
37 end
38
39 directory "/srv/community.openstreetmap.org/shared" do
40   owner "community"
41   group "community"
42   mode "755"
43 end
44
45 git "/srv/community.openstreetmap.org/docker" do
46   action :sync
47   repository "https://github.com/discourse/discourse_docker.git"
48   revision "main"
49   depth 1
50   user "root"
51   group "root"
52   notifies :run, "execute[discourse_container_data_rebuild]"
53   notifies :run, "execute[discourse_container_web_only_rebuild]"
54 end
55
56 template "/srv/community.openstreetmap.org/docker/containers/data.yml" do
57   source "data.yml.erb"
58   owner "root"
59   group "root"
60   mode "644"
61   variables :license_keys => license_keys, :passwords => passwords
62   notifies :run, "execute[discourse_container_data_rebuild]"
63 end
64
65 template "/srv/community.openstreetmap.org/docker/containers/web_only.yml" do
66   source "web_only.yml.erb"
67   owner "root"
68   group "root"
69   mode "644"
70   variables :license_keys => license_keys, :passwords => passwords
71   notifies :run, "execute[discourse_container_web_only_rebuild]"
72 end
73
74 execute "discourse_container_data_rebuild" do
75   action :nothing
76   command "./launcher rebuild data"
77   cwd "/srv/community.openstreetmap.org/docker/"
78   user "root"
79   group "root"
80 end
81
82 execute "discourse_container_web_only_rebuild" do
83   action :nothing
84   command "./launcher rebuild web_only"
85   cwd "/srv/community.openstreetmap.org/docker/"
86   user "root"
87   group "root"
88 end
89
90 ## FIXME
91 # Backup the backups
92 # Maybe use /srv/community.openstreetmap.org/shared/web-only/backups/
93 # Or https://github.com/discourse/discourse_docker/blob/8b0ae9b4da2f48d62d7a88035018dba403918325/templates/postgres.template.yml#L240
94 #    and tar of the shared web uploads