From d09dc50d0faafc849f270bcac0cf77302799d627 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 10 Mar 2023 12:50:55 +0100 Subject: [PATCH] Enable multinode servers to use external db --- manifests/app_type.pp | 4 ++++ manifests/multinode.pp | 13 ++++++++++++- templates/application/config.php.erb | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/manifests/app_type.pp b/manifests/app_type.pp index a7c9533..e3ae1ec 100644 --- a/manifests/app_type.pp +++ b/manifests/app_type.pp @@ -16,6 +16,8 @@ define sunetdrive::app_type ( # Other settings $admin_password = $config[ 'admin_password' ] $dbhost = $config[ 'dbhost' ] + $dbname = $config[ 'dbname' ] + $dbuser = $config[ 'dbuser' ] $instanceid = $config[ 'instanceid' ] $mysql_user_password = $config[ 'mysql_user_password' ] $passwordsalt = $config[ 'passwordsalt' ] @@ -30,6 +32,8 @@ define sunetdrive::app_type ( # Other settings $admin_password = safe_hiera('admin_password') $dbhost = 'proxysql_proxysql_1' + $dbname = 'nextcloud' + $dbuser = 'nextcloud' $instanceid = safe_hiera('instanceid') $mysql_user_password = safe_hiera('mysql_user_password') $passwordsalt = safe_hiera('passwordsalt') diff --git a/manifests/multinode.pp b/manifests/multinode.pp index e0e3a68..3722080 100644 --- a/manifests/multinode.pp +++ b/manifests/multinode.pp @@ -212,7 +212,16 @@ MACAddressPolicy=none' $cron_log_path ="/opt/multinode/${customer}/cron.log" $customer_config_full = hiera_hash($customer) $customer_config = $customer_config_full[$environment] - $dbhost = "mariadb-${customer}_db_1" + + if $customer in ['vr'] and $environment == 'test' { + $dbhost = 'proxysql_proxysql_1' + $dbname = "nextcloud_${customer}" + $dbuser = "nextcloud_${customer}" + } else { + $dbhost = "mariadb-${customer}_db_1" + $dbname = 'nextcloud' + $dbuser = 'nextcloud' + } $gs_enabled = hiera('gs_enabled') $gs_federation = hiera('gs_federation') @@ -254,6 +263,8 @@ MACAddressPolicy=none' admin_password => $admin_password, backup_password => $backup_password, dbhost => $dbhost, + dbname => $dbname, + dbuser => $dbuser, drive_email_template_plain_text_left => hiera($environment)['drive_email_template_plain_text_left'], drive_email_template_text_left => hiera($environment)['drive_email_template_text_left'], drive_email_template_url_left => hiera($environment)['drive_email_template_url_left'], diff --git a/templates/application/config.php.erb b/templates/application/config.php.erb index 5fe941d..424c531 100644 --- a/templates/application/config.php.erb +++ b/templates/application/config.php.erb @@ -124,12 +124,12 @@ $CONFIG = array ( 'config_is_read_only' => true, 'datadirectory' => '/var/www/html/data', 'dbhost' => '<%= @dbhost %>', - 'dbname' => 'nextcloud', + 'dbname' => '<%= @dbname %>', 'dbpassword' => '<%= @mysql_user_password %>', 'dbport' => '3306', 'dbtableprefix' => 'oc_', 'dbtype' => 'mysql', - 'dbuser' => 'nextcloud', + 'dbuser' => '<%= @dbuser %>', 'drive_email_template_text_left' => '<%= @drive_email_template_text_left %>', 'drive_email_template_plain_text_left' => '<%= @drive_email_template_plain_text_left %>', 'drive_email_template_url_left' => '<%= @drive_email_template_url_left %>',