Create a discourse cookbook that can be wrapped

It makes it possible to serve multiple Discord instances to different
hosts from a single nginx load balancer

Right now we run one for Kosmos and one for remoteStorage
This commit is contained in:
Greg Karékinian
2022-10-11 17:58:22 +02:00
parent e90b265f7e
commit 378fee85ec
30 changed files with 537 additions and 84 deletions

View File

@@ -1,7 +1,5 @@
# kosmos_discourse CHANGELOG
This file is used to list changes made in each version of the kosmos_discourse cookbook.
# 0.1.0
Initial release.

View File

@@ -1,4 +1,3 @@
# kosmos_discourse
TODO: Enter the cookbook description here.
Wrapper cookbook based on discourse

View File

@@ -0,0 +1,2 @@
node.override['discourse']['domain'] = "community.kosmos.org"
node.override['discourse']['role'] = "kosmos_discourse"

View File

@@ -1,12 +1,10 @@
name 'kosmos_discourse'
maintainer 'Kosmos Developers'
maintainer_email 'you@example.com'
maintainer_email 'mail@kosmos.org'
license 'MIT'
description 'Installs/Configures kosmos_discourse'
long_description 'Installs/Configures kosmos_discourse'
description 'Installs/Configures discourse'
long_description 'Installs/Configures discourse'
version '0.1.0'
chef_version '>= 14.0'
depends 'kosmos-nginx'
depends 'firewall'
depends 'kosmos-dirsrv'
depends 'discourse'

View File

@@ -3,43 +3,4 @@
# Recipe:: default
#
include_recipe "kosmos-dirsrv::hostsfile"
package "docker-compose"
deploy_path = "/opt/discourse"
repo = "https://github.com/discourse/discourse_docker"
git deploy_path do
repository repo
revision "main"
end
systemd_unit "discourse.service" do
content({Unit: {
Description: "discourse service with docker compose",
Requires: "docker.service",
After: "docker.service",
},
Service: {
Type: "oneshot",
RemainAfterExit: "true",
WorkingDirectory: deploy_path,
Environment: "SUPERVISED=true",
ExecStart: "#{deploy_path}/launcher start app",
ExecStop: "#{deploy_path}/launcher stop app",
},
Install: {
WantedBy: "multi-user.target"
}})
action [:create, :enable]
end
include_recipe 'firewall'
firewall_rule 'discourse' do
port [3001]
source "10.1.1.0/24"
protocol :tcp
command :allow
end
include_recipe 'discourse'

View File

@@ -3,32 +3,4 @@
# Recipe:: nginx
#
include_recipe "kosmos-nginx"
domain = "community.kosmos.org"
upstream_ip_addresses = []
search(:node, "role:discourse").each do |n|
upstream_ip_addresses << n["knife_zero"]["host"]
end
# No Discourse host, stop here
return if upstream_ip_addresses.empty?
nginx_certbot_site domain
template "#{node['nginx']['dir']}/sites-available/#{domain}" do
source "nginx_conf.erb"
owner 'www-data'
mode 0640
variables server_name: domain,
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem",
upstream_port: 3001,
upstream_ip_addresses: upstream_ip_addresses
notifies :reload, 'service[nginx]', :delayed
end
nginx_site domain do
action :enable
end
include_recipe "discourse::nginx"