Merge branch 'main' into mandersson-nmhost

This commit is contained in:
Micke Nordin 2024-05-07 13:09:29 +02:00
commit 47bf118116
3 changed files with 38 additions and 18 deletions

View file

@ -219,6 +219,8 @@ MACAddressPolicy=none'
} }
} }
$customers.each | $index, $customer | { $customers.each | $index, $customer | {
$customer_config_full = hiera_hash($customer)
$customer_config = $customer_config_full[$environment]
cron { "multinode_cron_${customer}": cron { "multinode_cron_${customer}":
command => "/opt/nextcloud/cron.sh nextcloud-${customer}_app_1", command => "/opt/nextcloud/cron.sh nextcloud-${customer}_app_1",
require => File['/opt/nextcloud/cron.sh'], require => File['/opt/nextcloud/cron.sh'],
@ -226,11 +228,19 @@ MACAddressPolicy=none'
minute => '*/10', minute => '*/10',
} }
if $environment == 'prod' { 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" $site_name = "${customer}.drive.sunet.se"
$trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se'] $trusted_proxies = ['lb1.drive.sunet.se','lb2.drive.sunet.se', 'lb3.drive.sunet.se', 'lb4.drive.sunet.se']
} else { } else {
$s3_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" $site_name = "${customer}.drive.${environment}.sunet.se"
$trusted_proxies = ["lb1.drive.${environment}.sunet.se","lb2.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"] "lb3.drive.${environment}.sunet.se","lb4.drive.${environment}.sunet.se"]
@ -239,8 +249,6 @@ MACAddressPolicy=none'
$apache_error_path = "/opt/multinode/${customer}/404.html" $apache_error_path = "/opt/multinode/${customer}/404.html"
$config_php_path = "/opt/multinode/${customer}/config.php" $config_php_path = "/opt/multinode/${customer}/config.php"
$cron_log_path ="/opt/multinode/${customer}/cron.log" $cron_log_path ="/opt/multinode/${customer}/cron.log"
$customer_config_full = hiera_hash($customer)
$customer_config = $customer_config_full[$environment]
$dbhost = 'proxysql_proxysql_1' $dbhost = 'proxysql_proxysql_1'
$dbname = "nextcloud_${customer}" $dbname = "nextcloud_${customer}"

View file

@ -30,7 +30,10 @@ def add_downtime(fqdn: str,
post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format( post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format(
monitor_host, fqdn, action) monitor_host, fqdn, action)
headers = {'X-Thruk-Auth-Key': apikey} 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, def remove_downtime(fqdn: str,
@ -42,12 +45,15 @@ def remove_downtime(fqdn: str,
get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format( get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format(
monitor_host, fqdn) monitor_host, fqdn)
headers = {'X-Thruk-Auth-Key': apikey} headers = {'X-Thruk-Auth-Key': apikey}
req = requests.get(get_url, headers=headers) try:
action = 'del_active_service_downtimes' req = requests.get(get_url, headers=headers)
for service in req.json()[0]['services']: action = 'del_active_service_downtimes'
post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( for service in req.json()[0]['services']:
monitor_host, fqdn, urllib.parse.quote(service), action) post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format(
requests.post(post_url, headers=headers) 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: def main() -> int:

View file

@ -30,7 +30,10 @@ def add_downtime(fqdn: str,
post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format( post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format(
monitor_host, fqdn, action) monitor_host, fqdn, action)
headers = {'X-Thruk-Auth-Key': apikey} 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, def remove_downtime(fqdn: str,
@ -42,12 +45,15 @@ def remove_downtime(fqdn: str,
get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format( get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format(
monitor_host, fqdn) monitor_host, fqdn)
headers = {'X-Thruk-Auth-Key': apikey} headers = {'X-Thruk-Auth-Key': apikey}
req = requests.get(get_url, headers=headers) try:
action = 'del_active_service_downtimes' req = requests.get(get_url, headers=headers)
for service in req.json()[0]['services']: action = 'del_active_service_downtimes'
post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format( for service in req.json()[0]['services']:
monitor_host, fqdn, urllib.parse.quote(service), action) post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format(
requests.post(post_url, headers=headers) 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: def run_command(command: list) -> tuple: