5 # Copyright:: 2021, OpenStreetMap Foundation
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
20 include_recipe "accounts"
21 include_recipe "docker"
25 passwords = data_bag_item("community", "passwords")
26 license_keys = data_bag_item("geoipupdate", "license-keys") unless kitchen?
28 # Disable any default installed apache2 service. Web server is embedded within the discourse docker container
30 action [:disable, :stop]
33 directory "/srv/community.openstreetmap.org" do
39 directory "/srv/community.openstreetmap.org/shared" do
45 directory "/srv/community.openstreetmap.org/files" do
51 template "/srv/community.openstreetmap.org/files/update-feeds.atom" do
52 source "update-feeds.atom.erb"
58 git "/srv/community.openstreetmap.org/docker" do
60 repository "https://github.com/discourse/discourse_docker.git"
61 # Revision pin not possible as launch wrapper automatically updates git repo.
66 notifies :run, "notify_group[discourse_container_new_data]"
67 notifies :run, "notify_group[discourse_container_new_web_only]"
68 notifies :run, "notify_group[discourse_container_new_mail_receiver]"
71 template "/srv/community.openstreetmap.org/docker/containers/data.yml" do
76 variables :passwords => passwords
77 notifies :run, "notify_group[discourse_container_new_data]"
80 template "/srv/community.openstreetmap.org/docker/containers/web_only.yml" do
81 source "web_only.yml.erb"
85 variables :license_keys => license_keys, :passwords => passwords
86 notifies :run, "notify_group[discourse_container_new_web_only]"
89 template "/srv/community.openstreetmap.org/docker/containers/mail-receiver.yml" do
90 source "mail-receiver.yml.erb"
94 variables :passwords => passwords
95 notifies :run, "notify_group[discourse_container_new_mail_receiver]"
98 ssl_certificate "community.openstreetmap.org" do
99 domains ["community.openstreetmap.org", "community.osm.org", "communities.openstreetmap.org", "communities.osm.org", "c.openstreetmap.org", "c.osm.org", "forum.openstreetmap.org", "forum.osm.org"]
100 notifies :run, "notify_group[discourse_container_new_web_only]"
101 notifies :run, "notify_group[discourse_container_new_mail_receiver]"
104 notify_group "discourse_container_new_web_only" do
105 notifies :run, "execute[discourse_container_data_start]", :immediately # noop if site up
106 notifies :run, "execute[discourse_container_web_only_bootstrap]", :immediately # site up but runs in parallel. Slow
107 notifies :run, "execute[discourse_container_web_only_destroy]", :immediately # site down
108 notifies :run, "execute[discourse_container_data_rebuild]", :immediately # site down
109 notifies :run, "execute[discourse_container_web_only_start]", :immediately # site restore
112 notify_group "discourse_container_new_data" do
113 notifies :run, "execute[discourse_container_web_only_destroy]", :immediately # site down
114 notifies :run, "execute[discourse_container_data_rebuild]", :immediately # site down
115 notifies :run, "execute[discourse_container_web_only_start]", :immediately # site restore
118 notify_group "discourse_container_new_mail_receiver" do
119 notifies :run, "execute[discourse_container_mail_receiver_rebuild]", :immediately
122 # Attempt at a failsafe to ensure all containers are running
123 notify_group "discourse_container_ensure_all_running" do
125 notifies :run, "execute[discourse_container_data_start]", :delayed
126 notifies :run, "execute[discourse_container_web_only_start]", :delayed
127 notifies :run, "execute[discourse_container_mail_receiver_start]", :delayed
130 execute "discourse_container_data_start" do
132 command "./launcher start data"
133 cwd "/srv/community.openstreetmap.org/docker/"
138 execute "discourse_container_data_rebuild" do
140 command "./launcher rebuild data"
141 cwd "/srv/community.openstreetmap.org/docker/"
146 execute "discourse_container_web_only_bootstrap" do
148 command "./launcher bootstrap web_only"
149 cwd "/srv/community.openstreetmap.org/docker/"
154 execute "discourse_container_web_only_destroy" do
156 command "./launcher destroy web_only"
157 cwd "/srv/community.openstreetmap.org/docker/"
162 execute "discourse_container_web_only_start" do
164 command "./launcher start web_only"
165 cwd "/srv/community.openstreetmap.org/docker/"
170 # Rebuild: Stop Destroy Bootstap Start
171 execute "discourse_container_mail_receiver_rebuild" do
173 command "./launcher rebuild mail-receiver"
174 cwd "/srv/community.openstreetmap.org/docker/"
179 execute "discourse_container_mail_receiver_start" do
181 command "./launcher start mail-receiver"
182 cwd "/srv/community.openstreetmap.org/docker/"
187 template "/etc/cron.daily/community-backup" do
188 source "backup.cron.erb"
194 node.default[:prometheus][:exporters][443] = {
195 :name => "community",
196 :address => "#{node[:prometheus][:address]}:443",
197 :sni => "community.openstreetmap.org"