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"
22 include_recipe "geoipupdate"
26 passwords = data_bag_item("community", "passwords")
27 license_keys = data_bag_item("geoipupdate", "license-keys") unless kitchen?
29 directory "/srv/community.openstreetmap.org" do
35 directory "/srv/community.openstreetmap.org/shared" do
41 git "/srv/community.openstreetmap.org/docker" do
43 repository "https://github.com/discourse/discourse_docker.git"
48 notifies :run, "execute[discourse_container_data_rebuild]"
49 notifies :run, "execute[discourse_container_web_only_bootstrap]"
50 notifies :run, "execute[discourse_container_mail_receiver_rebuild]"
53 template "/srv/community.openstreetmap.org/docker/containers/data.yml" do
58 variables :passwords => passwords
59 notifies :run, "execute[discourse_container_data_rebuild]"
62 template "/srv/community.openstreetmap.org/docker/containers/web_only.yml" do
63 source "web_only.yml.erb"
67 variables :license_keys => license_keys, :passwords => passwords
68 notifies :run, "execute[discourse_container_web_only_bootstrap]"
71 template "/srv/community.openstreetmap.org/docker/containers/mail-receiver.yml" do
72 source "mail-receiver.yml.erb"
76 variables :passwords => passwords
77 notifies :run, "execute[discourse_container_mail_receiver_rebuild]"
80 # Destroy Bootstap Start
81 execute "discourse_container_data_rebuild" do
83 command "./launcher rebuild data"
84 cwd "/srv/community.openstreetmap.org/docker/"
89 ssl_certificate "community.openstreetmap.org" do
90 domains ["community.openstreetmap.org", "community.osm.org", "communities.openstreetmap.org", "communities.osm.org"]
91 notifies :run, "execute[discourse_container_web_only_bootstrap]"
94 execute "discourse_container_data_start" do
96 command "./launcher start data"
97 cwd "/srv/community.openstreetmap.org/docker/"
102 execute "discourse_container_web_only_bootstrap" do
104 command "./launcher bootstrap web_only"
105 cwd "/srv/community.openstreetmap.org/docker/"
108 notifies :run, "execute[discourse_container_web_only_destroy]", :immediately
111 execute "discourse_container_web_only_destroy" do
113 command "./launcher destroy web_only"
114 cwd "/srv/community.openstreetmap.org/docker/"
117 notifies :run, "execute[discourse_container_web_only_start]", :immediately
120 execute "discourse_container_web_only_start" do
122 command "./launcher start web_only"
123 cwd "/srv/community.openstreetmap.org/docker/"
126 notifies :run, "execute[discourse_container_data_start]", :before
129 # Destroy Bootstap Start
130 execute "discourse_container_mail_receiver_rebuild" do
132 command "./launcher rebuild mail-receiver"
133 cwd "/srv/community.openstreetmap.org/docker/"
138 template "/etc/cron.daily/community-backup" do
139 source "backup.cron.erb"
145 node.default[:prometheus][:exporters][443] = {
146 :name => "community",
147 :address => "#{node[:prometheus][:address]}:443",
148 :sni => "community.openstreetmap.org"