From 9096bf7c338f890c9d55bb54132ab5dff421ee21 Mon Sep 17 00:00:00 2001
From: Rikard Danielsson <richir@sunet.se>
Date: Wed, 5 Mar 2025 16:22:29 +0100
Subject: [PATCH] separating multinode from app_type

---
 manifests/app_type.pp  | 35 +++++++++++++++++------------------
 manifests/multinode.pp | 15 +++++++++++++++
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/manifests/app_type.pp b/manifests/app_type.pp
index a674929..155f93e 100644
--- a/manifests/app_type.pp
+++ b/manifests/app_type.pp
@@ -101,6 +101,23 @@ define sunetdrive::app_type (
       content => template('sunetdrive/application/get_containers'),
       mode    => '0744',
     }
+    if ($nodenumber == 3) {
+      file { '/usr/lib/nagios/plugins/check_nextcloud_mounts.py':
+        ensure  => present,
+        owner   => 'root',
+        group   => 'root',
+        content => template('sunetdrive/application/check_nextcloud_mounts.py'),
+        mode    => '0744',
+      }
+      sunet::sudoer {'nagios_run_nextcloud_mounts_command':
+        user_name    => 'nagios',
+        collection   => 'nrpe_nextcloud_mounts_check',
+        command_line => '/usr/lib/nagios/plugins/check_nextcloud_mounts.py'
+      }
+      sunet::nagios::nrpe_command {'check_nextcloud_mounts':
+        command_line => '/usr/bin/sudo /usr/lib/nagios/plugins/check_nextcloud_mounts.py'
+      }
+    }
     if ($nodenumber == 3) {
       file { '/usr/local/bin/scan_external_mounts':
         ensure  => present,
@@ -388,22 +405,4 @@ define sunetdrive::app_type (
       }
     }
   }
-  if $facts['networking']['hostname'] == 'node1' or $facts['networking']['hostname'] =~ /^multinode[1-9]+$/{
-    file { '/usr/lib/nagios/plugins/check_nextcloud_mounts.py':
-      ensure  => present,
-      force   => true,
-      owner   => 'root',
-      group   => 'root',
-      content => template('sunetdrive/application/check_nextcloud_mounts.py'),
-      mode    => '0744',
-    }
-    sunet::sudoer {'nagios_run_nextcloud_mounts_command':
-      user_name    => 'nagios',
-      collection   => 'nrpe_nextcloud_mounts_check',
-      command_line => '/usr/lib/nagios/plugins/check_nextcloud_mounts.py'
-    }
-    sunet::nagios::nrpe_command {'check_nextcloud_mounts':
-      command_line => '/usr/bin/sudo /usr/lib/nagios/plugins/check_nextcloud_mounts.py'
-    }
-  }
 }
diff --git a/manifests/multinode.pp b/manifests/multinode.pp
index 7cf12b8..90cc651 100644
--- a/manifests/multinode.pp
+++ b/manifests/multinode.pp
@@ -46,6 +46,21 @@ class sunetdrive::multinode (
     content => template('sunetdrive/application/get_containers'),
     mode    => '0744',
   }
+  file { '/usr/lib/nagios/plugins/check_nextcloud_mounts.py':
+    ensure  => present,
+    owner   => 'root',
+    group   => 'root',
+    content => template('sunetdrive/application/check_nextcloud_mounts.py'),
+    mode    => '0744',
+  }
+  sunet::sudoer {'nagios_run_nextcloud_mounts_command':
+    user_name    => 'nagios',
+    collection   => 'nrpe_nextcloud_mounts_check',
+    command_line => '/usr/lib/nagios/plugins/check_nextcloud_mounts.py'
+  }
+  sunet::nagios::nrpe_command {'check_nextcloud_mounts':
+    command_line => '/usr/bin/sudo /usr/lib/nagios/plugins/check_nextcloud_mounts.py'
+  }
   file { '/usr/local/bin/scan_external_mounts':
     ensure  => present,
     force   => true,