|
|
|
@@ -31,6 +31,52 @@ ruby_version = "2.7.5"
|
|
|
|
|
bundle_path = "/opt/ruby_build/builds/#{ruby_version}/bin/bundle"
|
|
|
|
|
rails_env = node.chef_environment == "development" ? "development" : "production"
|
|
|
|
|
|
|
|
|
|
postgres_readonly_host = search(:node, "role:postgresql_replica").first["knife_zero"]["host"] rescue nil
|
|
|
|
|
btcpay_host = search(:node, "role:btcpay").first["knife_zero"]["host"] rescue nil
|
|
|
|
|
lndhub_host = search(:node, "role:lndhub").first["knife_zero"]["host"] rescue nil
|
|
|
|
|
webhooks_allowed_ips = [lndhub_host].compact.uniq.join(',')
|
|
|
|
|
env = {}
|
|
|
|
|
|
|
|
|
|
if webhooks_allowed_ips.length > 0
|
|
|
|
|
env[:webhooks_allowed_ips] = webhooks_allowed_ips
|
|
|
|
|
end
|
|
|
|
|
if btcpay_host
|
|
|
|
|
env[:btcpay_api_url] = "http://#{btcpay_host}:23001/api/v1"
|
|
|
|
|
end
|
|
|
|
|
if lndhub_host
|
|
|
|
|
node.override["akkounts"]["lndhub"]["api_url"] = "http://#{lndhub_host}:3026"
|
|
|
|
|
env[:lndhub_legacy_api_url] = node["akkounts"]["lndhub"]["api_url"]
|
|
|
|
|
env[:lndhub_api_url] = node["akkounts"]["lndhub"]["api_url"]
|
|
|
|
|
env[:lndhub_public_url] = node["akkounts"]["lndhub"]["public_url"]
|
|
|
|
|
if postgres_readonly_host
|
|
|
|
|
env[:lndhub_admin_ui] = true
|
|
|
|
|
env[:lndhub_pg_host] = postgres_readonly_host
|
|
|
|
|
env[:lndhub_pg_database] = node['akkounts']['lndhub']['postgres_db']
|
|
|
|
|
env[:lndhub_pg_username] = credentials['postgresql_username']
|
|
|
|
|
env[:lndhub_pg_password] = credentials['postgresql_password']
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ejabberd_private_ip_addresses = []
|
|
|
|
|
search(:node, "role:ejabberd").each do |node|
|
|
|
|
|
ejabberd_private_ip_addresses << node["knife_zero"]["host"]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ejabberd_private_ip_addresses.each do |ip_address|
|
|
|
|
|
IPAddr.new ip_address
|
|
|
|
|
hostsfile_entry ip_address do
|
|
|
|
|
hostname 'xmpp.kosmos.org'
|
|
|
|
|
action :create
|
|
|
|
|
end
|
|
|
|
|
rescue IPAddr::InvalidAddressError
|
|
|
|
|
ejabberd_private_ip_addresses.delete! ip_address
|
|
|
|
|
next
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if ejabberd_private_ip_addresses.size > 0
|
|
|
|
|
env[:ejabberd_api_url] = 'https://xmpp.kosmos.org:5443/api'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
systemd_unit "akkounts.service" do
|
|
|
|
|
content({
|
|
|
|
|
Unit: {
|
|
|
|
@@ -120,6 +166,16 @@ application deploy_path do
|
|
|
|
|
group deploy_group
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
template "#{deploy_path}/.env.production" do
|
|
|
|
|
source 'env.production.erb'
|
|
|
|
|
owner deploy_user
|
|
|
|
|
group deploy_group
|
|
|
|
|
mode 0600
|
|
|
|
|
sensitive true
|
|
|
|
|
variables config: env
|
|
|
|
|
notifies :restart, "application[#{deploy_path}]", :delayed
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
execute "bundle install" do
|
|
|
|
|
environment "HOME" => deploy_path
|
|
|
|
|
user deploy_user
|
|
|
|
@@ -159,21 +215,6 @@ application deploy_path do
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ejabberd_private_ip_addresses = []
|
|
|
|
|
search(:node, "role:ejabberd").each do |node|
|
|
|
|
|
ejabberd_private_ip_addresses << node["knife_zero"]["host"]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ejabberd_private_ip_addresses.each do |ip_address|
|
|
|
|
|
IPAddr.new ip_address
|
|
|
|
|
hostsfile_entry ip_address do
|
|
|
|
|
hostname 'xmpp.kosmos.org'
|
|
|
|
|
action :create
|
|
|
|
|
end
|
|
|
|
|
rescue IPAddr::InvalidAddressError
|
|
|
|
|
next
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO move to nginx proxy
|
|
|
|
|
include_recipe 'kosmos-akkounts::nginx'
|
|
|
|
|
|
|
|
|
|