From d13b22e3a254912c8b6ce62699dd1e51088b4233 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 29 Apr 2024 16:25:22 +0200 Subject: [PATCH 1/6] Make it possible to configure s3 bucket --- manifests/multinode.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/multinode.pp b/manifests/multinode.pp index 0e65575..024d3b0 100644 --- a/manifests/multinode.pp +++ b/manifests/multinode.pp @@ -230,7 +230,8 @@ MACAddressPolicy=none' $site_name = "${customer}.drive.sunet.se" $trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se'] } else { - $s3_bucket = "primary-${customer}-${environment}.sunet.se" + + $s3_bucket = pick($customer_config["primary_bucket"],"primary-${customer}-${environment}.sunet.se"]}) $site_name = "${customer}.drive.${environment}.sunet.se" $trusted_proxies = ["lb1.drive.${environment}.sunet.se","lb2.drive.${environment}.sunet.se", "lb3.drive.${environment}.sunet.se","lb4.drive.${environment}.sunet.se"] From d33f80273de74117d2165cf7955e7d3deebd7964 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 29 Apr 2024 16:29:50 +0200 Subject: [PATCH 2/6] Fix syntax --- manifests/multinode.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/multinode.pp b/manifests/multinode.pp index 024d3b0..0486b70 100644 --- a/manifests/multinode.pp +++ b/manifests/multinode.pp @@ -231,7 +231,7 @@ MACAddressPolicy=none' $trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se'] } else { - $s3_bucket = pick($customer_config["primary_bucket"],"primary-${customer}-${environment}.sunet.se"]}) + $s3_bucket = pick($customer_config["primary_bucket"],"primary-${customer}-${environment}.sunet.se") $site_name = "${customer}.drive.${environment}.sunet.se" $trusted_proxies = ["lb1.drive.${environment}.sunet.se","lb2.drive.${environment}.sunet.se", "lb3.drive.${environment}.sunet.se","lb4.drive.${environment}.sunet.se"] From bd074c73d509b11b4f743deea75197a6eb2079bf Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 29 Apr 2024 16:34:38 +0200 Subject: [PATCH 3/6] Fix syntax --- manifests/multinode.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/multinode.pp b/manifests/multinode.pp index 0486b70..c3e2614 100644 --- a/manifests/multinode.pp +++ b/manifests/multinode.pp @@ -231,7 +231,11 @@ MACAddressPolicy=none' $trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se'] } else { - $s3_bucket = pick($customer_config["primary_bucket"],"primary-${customer}-${environment}.sunet.se") + if "primary_bucket" in $customer_config.keys() { + $s3_bucket = $customer_config["primary_bucket"] + } else { + $s3_bucket = "primary-${customer}-${environment}.sunet.se" + } $site_name = "${customer}.drive.${environment}.sunet.se" $trusted_proxies = ["lb1.drive.${environment}.sunet.se","lb2.drive.${environment}.sunet.se", "lb3.drive.${environment}.sunet.se","lb4.drive.${environment}.sunet.se"] From 27d0bc15cc18b0ad99f08fa20f65addc64b4c577 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Mon, 29 Apr 2024 16:39:23 +0200 Subject: [PATCH 4/6] Move config def up --- manifests/multinode.pp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/manifests/multinode.pp b/manifests/multinode.pp index c3e2614..040a783 100644 --- a/manifests/multinode.pp +++ b/manifests/multinode.pp @@ -219,6 +219,8 @@ MACAddressPolicy=none' } } $customers.each | $index, $customer | { + $customer_config_full = hiera_hash($customer) + $customer_config = $customer_config_full[$environment] cron { "multinode_cron_${customer}": command => "/opt/nextcloud/cron.sh nextcloud-${customer}_app_1", require => File['/opt/nextcloud/cron.sh'], @@ -226,13 +228,16 @@ MACAddressPolicy=none' minute => '*/10', } if $environment == 'prod' { - $s3_bucket = "primary-${customer}-drive.sunet.se" + if 'primary_bucket' in $customer_config.keys() { + $s3_bucket = $customer_config['primary_bucket'] + } else { + $s3_bucket = "primary-${customer}-drive.sunet.se" + } $site_name = "${customer}.drive.sunet.se" $trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se'] } else { - - if "primary_bucket" in $customer_config.keys() { - $s3_bucket = $customer_config["primary_bucket"] + if 'primary_bucket' in $customer_config.keys() { + $s3_bucket = $customer_config['primary_bucket'] } else { $s3_bucket = "primary-${customer}-${environment}.sunet.se" } @@ -244,8 +249,6 @@ MACAddressPolicy=none' $apache_error_path = "/opt/multinode/${customer}/404.html" $config_php_path = "/opt/multinode/${customer}/config.php" $cron_log_path ="/opt/multinode/${customer}/cron.log" - $customer_config_full = hiera_hash($customer) - $customer_config = $customer_config_full[$environment] $dbhost = 'proxysql_proxysql_1' $dbname = "nextcloud_${customer}" From cb16f037104640cff3844e469d9bb10d023274d3 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Tue, 7 May 2024 10:50:55 +0200 Subject: [PATCH 5/6] Don't fail on problems with downtime --- templates/script/restart-nextcloud-farm.erb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/templates/script/restart-nextcloud-farm.erb b/templates/script/restart-nextcloud-farm.erb index bb5170a..2a01450 100755 --- a/templates/script/restart-nextcloud-farm.erb +++ b/templates/script/restart-nextcloud-farm.erb @@ -30,7 +30,10 @@ def add_downtime(fqdn: str, post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format( monitor_host, fqdn, action) headers = {'X-Thruk-Auth-Key': apikey} - requests.post(post_url, data=data, headers=headers) + try: + requests.post(post_url, data=data, headers=headers) + except Exception: + print("Failed to add downtime for: {}".format(fqdn)) def remove_downtime(fqdn: str, @@ -42,12 +45,15 @@ def remove_downtime(fqdn: str, get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format( monitor_host, fqdn) headers = {'X-Thruk-Auth-Key': apikey} - req = requests.get(get_url, headers=headers) - action = 'del_active_service_downtimes' - for service in req.json()[0]['services']: - post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( - monitor_host, fqdn, urllib.parse.quote(service), action) - requests.post(post_url, headers=headers) + try: + req = requests.get(get_url, headers=headers) + action = 'del_active_service_downtimes' + for service in req.json()[0]['services']: + post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( + monitor_host, fqdn, urllib.parse.quote(service), action) + requests.post(post_url, headers=headers) + except Exception: + print("Failed to remove downtime for: {}".format(fqdn)) def run_command(command: list) -> tuple: From 51a695ed9eaa2c8518039aca0adfa1f69010ac06 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Tue, 7 May 2024 10:53:44 +0200 Subject: [PATCH 6/6] Don't fail on problems with downtime for db either --- templates/script/restart-db-cluster.erb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/templates/script/restart-db-cluster.erb b/templates/script/restart-db-cluster.erb index 6ea18ba..418512c 100755 --- a/templates/script/restart-db-cluster.erb +++ b/templates/script/restart-db-cluster.erb @@ -30,7 +30,10 @@ def add_downtime(fqdn: str, post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format( monitor_host, fqdn, action) headers = {'X-Thruk-Auth-Key': apikey} - requests.post(post_url, data=data, headers=headers) + try: + requests.post(post_url, data=data, headers=headers) + except Exception: + print("Failed to add downtime for {}".format(fqdn)) def remove_downtime(fqdn: str, @@ -42,12 +45,15 @@ def remove_downtime(fqdn: str, get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format( monitor_host, fqdn) headers = {'X-Thruk-Auth-Key': apikey} - req = requests.get(get_url, headers=headers) - action = 'del_active_service_downtimes' - for service in req.json()[0]['services']: - post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( - monitor_host, fqdn, urllib.parse.quote(service), action) - requests.post(post_url, headers=headers) + try: + req = requests.get(get_url, headers=headers) + action = 'del_active_service_downtimes' + for service in req.json()[0]['services']: + post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( + monitor_host, fqdn, urllib.parse.quote(service), action) + requests.post(post_url, headers=headers) + except Exception: + print("Failed to remove downtime for {}".format(fqdn)) def main() -> int: