From 01977e088a5dc617173ac84e259b388a685df3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 28 Jun 2023 14:27:25 +0200 Subject: [PATCH] Configure remaining options for akkounts And refactor attributes/variables to use the various service cookbook's own attributes. --- environments/production.json | 12 +++++- .../kosmos-akkounts/attributes/default.rb | 2 +- .../kosmos-akkounts/recipes/default.rb | 38 +++++++++++-------- .../kosmos-mastodon/attributes/default.rb | 2 +- .../kosmos-mastodon/recipes/default.rb | 4 +- .../kosmos-mastodon/recipes/nginx.rb | 2 +- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/environments/production.json b/environments/production.json index 0d0d0ac..538483e 100644 --- a/environments/production.json +++ b/environments/production.json @@ -2,14 +2,17 @@ "name": "production", "override_attributes": { "akkounts": { - "discourse": { - "public_url": "https://community.kosmos.org" + "ejabberd": { + "admin_url": "https://xmpp.kosmos.org:5443/admin" }, "lndhub": { "public_url": "https://lndhub.kosmos.org", "public_key": "024cd3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946" } }, + "discourse": { + "domain": "community.kosmos.org" + }, "garage": { "replication_mode": "2", "s3_api_root_domain": ".s3.garage.kosmos.org", @@ -20,6 +23,7 @@ ] }, "gitea": { + "domain": "gitea.kosmos.org", "postgresql_host": "pg.kosmos.local:5432", "config": { "storage": { @@ -31,6 +35,7 @@ } }, "kosmos-mastodon": { + "domain": "kosmos.social", "s3_endpoint": "http://localhost:3900", "s3_region": "garage", "s3_bucket": "kosmos-social", @@ -40,6 +45,9 @@ "mastodon.w7nooprauv6yrnhzh2ajpcnj3doinked2aaztlwfyt6u6pva2qdxqhid.onion" ] }, + "mediawiki": { + "url": "https://wiki.kosmos.org" + }, "sentry": { "allowed_ips": "10.1.1.0/24" } diff --git a/site-cookbooks/kosmos-akkounts/attributes/default.rb b/site-cookbooks/kosmos-akkounts/attributes/default.rb index 7497790..4b8679a 100644 --- a/site-cookbooks/kosmos-akkounts/attributes/default.rb +++ b/site-cookbooks/kosmos-akkounts/attributes/default.rb @@ -11,7 +11,7 @@ node.default['akkounts']['smtp']['domain'] = 'kosmos.org' node.default['akkounts']['smtp']['auth_method'] = 'plain' node.default['akkounts']['smtp']['enable_starttls'] = 'auto' -node.default['akkounts']['discourse']['public_url'] = nil +node.default['akkounts']['ejabberd']['admin_url'] = nil node.default['akkounts']['lndhub']['api_url'] = nil node.default['akkounts']['lndhub']['public_url'] = nil diff --git a/site-cookbooks/kosmos-akkounts/recipes/default.rb b/site-cookbooks/kosmos-akkounts/recipes/default.rb index 976dd50..8091cc2 100644 --- a/site-cookbooks/kosmos-akkounts/recipes/default.rb +++ b/site-cookbooks/kosmos-akkounts/recipes/default.rb @@ -66,24 +66,9 @@ if btcpay_host env[:btcpay_api_url] = "http://#{btcpay_host}:23001/api/v1" end -env[:discourse_public_url] = node['akkounts']['discourse']['public_url'] +env[:discourse_public_url] = "https://#{node['discourse']['domain']}" env[:discourse_connect_secret] = credentials['discourse_connect_secret'] -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"] - env[:lndhub_public_key] = node["akkounts"]["lndhub"]["public_key"] - 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"] @@ -102,8 +87,29 @@ end if ejabberd_private_ip_addresses.size > 0 env[:ejabberd_api_url] = "http://xmpp.kosmos.local/api" + env[:ejabberd_admin_url] = node['akkounts']['ejabberd']['admin_url'] end +env[:gitea_public_url] = "https://#{node['gitea']['domain']}" + +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"] + env[:lndhub_public_key] = node["akkounts"]["lndhub"]["public_key"] + 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 + +env[:mastodon_public_url] = "https://#{node['kosmos-mastodon']['domain']}" +env[:mediawiki_public_url] = node['mediawiki']['url'] + systemd_unit "akkounts.service" do content({ Unit: { diff --git a/site-cookbooks/kosmos-mastodon/attributes/default.rb b/site-cookbooks/kosmos-mastodon/attributes/default.rb index 347595c..187d3e3 100644 --- a/site-cookbooks/kosmos-mastodon/attributes/default.rb +++ b/site-cookbooks/kosmos-mastodon/attributes/default.rb @@ -4,7 +4,7 @@ node.default["kosmos-mastodon"]["directory"] = "/opt/mastodon" node.default["kosmos-mastodon"]["bind_ip"] = "127.0.0.1" node.default["kosmos-mastodon"]["app_port"] = 3000 node.default["kosmos-mastodon"]["streaming_port"] = 4000 -node.default["kosmos-mastodon"]["server_name"] = "kosmos.social" +node.default["kosmos-mastodon"]["domain"] = "kosmos.social" node.default["kosmos-mastodon"]["alternate_domains"] = [] node.default["kosmos-mastodon"]["redis_url"] = "redis://localhost:6379/0" node.default["kosmos-mastodon"]["sidekiq_threads"] = 25 diff --git a/site-cookbooks/kosmos-mastodon/recipes/default.rb b/site-cookbooks/kosmos-mastodon/recipes/default.rb index 2dc8187..67db8ad 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/default.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/default.rb @@ -158,14 +158,14 @@ application mastodon_path do owner mastodon_user group mastodon_user variables redis_url: node["kosmos-mastodon"]["redis_url"], - domain: node["kosmos-mastodon"]["server_name"], + domain: node["kosmos-mastodon"]["domain"], alternate_domains: node["kosmos-mastodon"]["alternate_domains"], paperclip_secret: mastodon_credentials['paperclip_secret'], secret_key_base: mastodon_credentials['secret_key_base'], otp_secret: mastodon_credentials['otp_secret'], smtp_login: mastodon_credentials['smtp_user_name'], smtp_password: mastodon_credentials['smtp_password'], - smtp_from_address: "mail@#{node['kosmos-mastodon']['server_name']}", + smtp_from_address: "mail@#{node['kosmos-mastodon']['domain']}", s3_endpoint: node["kosmos-mastodon"]["s3_endpoint"], s3_region: node["kosmos-mastodon"]["s3_region"], s3_bucket: node["kosmos-mastodon"]["s3_bucket"], diff --git a/site-cookbooks/kosmos-mastodon/recipes/nginx.rb b/site-cookbooks/kosmos-mastodon/recipes/nginx.rb index 34575d0..3c81e81 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/nginx.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/nginx.rb @@ -6,7 +6,7 @@ include_recipe "kosmos-nginx" app_dir = node["kosmos-mastodon"]["directory"] -server_name = node["kosmos-mastodon"]["server_name"] +server_name = node["kosmos-mastodon"]["domain"] is_proxy = node.roles.include?('nginx_proxy') rescue nil upstream_hosts = []