35 lines
863 B
Ruby
35 lines
863 B
Ruby
#
|
|
# Cookbook:: kosmos_discourse
|
|
# 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
|