From bb0e73d1b9b8ae1e2c14e5ba1e5e6f5aa7a84ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Sat, 23 Jan 2021 16:43:15 +0100 Subject: [PATCH] Switch ejabberd, mastodon and gitea to a hostname for Postgres --- site-cookbooks/kosmos-ejabberd/recipes/default.rb | 7 +------ site-cookbooks/kosmos-mastodon/recipes/default.rb | 7 ++----- site-cookbooks/kosmos_gitea/recipes/default.rb | 6 +----- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/site-cookbooks/kosmos-ejabberd/recipes/default.rb b/site-cookbooks/kosmos-ejabberd/recipes/default.rb index dfffa4c..31e5994 100644 --- a/site-cookbooks/kosmos-ejabberd/recipes/default.rb +++ b/site-cookbooks/kosmos-ejabberd/recipes/default.rb @@ -138,11 +138,6 @@ ldap_base = "cn=users,dc=kosmos,dc=org" admin_users = ejabberd_credentials['admins'] -postgresql_primary_node = postgresql_primary -postgresql_server = postgresql_primary_node[:ipaddress] -# PostgreSQL is on the same server, connect through localhost -postgresql_server = "localhost" if postgresql_primary_node[:hostname] == node[:hostname] - hosts.each do |host| ldap_rootdn = "uid=xmpp,ou=#{host[:name]},cn=applications,dc=kosmos,dc=org" @@ -153,7 +148,7 @@ hosts.each do |host| group 'ejabberd' sensitive true variables pgsql_password: postgresql_data_bag_item['ejabberd_user_password'], - sql_server: postgresql_server, + sql_server: "pg.kosmos.local", host: host, ldap_base: ldap_base, ldap_server: ldap_domain, diff --git a/site-cookbooks/kosmos-mastodon/recipes/default.rb b/site-cookbooks/kosmos-mastodon/recipes/default.rb index ee9d5d6..37cf214 100644 --- a/site-cookbooks/kosmos-mastodon/recipes/default.rb +++ b/site-cookbooks/kosmos-mastodon/recipes/default.rb @@ -21,10 +21,6 @@ end elasticsearch_service 'elasticsearch' postgresql_data_bag_item = data_bag_item('credentials', 'postgresql') -postgresql_primary_node = postgresql_primary -postgresql_server = postgresql_primary_node[:ipaddress] -# PostgreSQL is on the same server, connect through localhost -postgresql_server = "localhost" if postgresql_primary_node[:hostname] == node[:hostname] mastodon_path = node["kosmos-mastodon"]["directory"] @@ -138,7 +134,8 @@ application mastodon_path do vapid_private_key: mastodon_credentials['vapid_private_key'], vapid_public_key: mastodon_credentials['vapid_public_key'], db_pass: postgresql_data_bag_item['mastodon_user_password'], - db_host: postgresql_server + db_host: "pg.kosmos.local" + notifies :restart, "application[#{mastodon_path}]", :delayed end execute "bundle install" do diff --git a/site-cookbooks/kosmos_gitea/recipes/default.rb b/site-cookbooks/kosmos_gitea/recipes/default.rb index 724572e..ba39c3c 100644 --- a/site-cookbooks/kosmos_gitea/recipes/default.rb +++ b/site-cookbooks/kosmos_gitea/recipes/default.rb @@ -37,10 +37,6 @@ smtp_credentials = data_bag_item("credentials", "smtp") jwt_secret = gitea_data_bag_item["jwt_secret"] internal_token = gitea_data_bag_item["internal_token"] secret_key = gitea_data_bag_item["secret_key"] -postgresql_primary_node = postgresql_primary -postgresql_server = postgresql_primary_node[:ipaddress] -# PostgreSQL is on the same server, connect through localhost -postgresql_server = "localhost" if postgresql_primary_node[:hostname] == node[:hostname] # Dependency package "git" @@ -110,7 +106,7 @@ template "#{config_directory}/app.ini" do jwt_secret: jwt_secret, internal_token: internal_token, secret_key: secret_key, - postgresql_host: "#{postgresql_server}:5432", + postgresql_host: "pg.kosmos.local:5432", postgresql_password: gitea_data_bag_item["postgresql_password"], smtp_host: smtp_credentials["relayhost"], smtp_user: smtp_credentials["user_name"],