]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Make mountpoints configurable
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 17 Aug 2018 15:40:59 +0000 (17:40 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 17 Aug 2018 15:43:16 +0000 (17:43 +0200)
modules/role/manifests/file_store.pp

index bf4afe7c4ea683d92507d88d8dd86479467decb3..d1f6a6794a6ccd2ea3448bcf30bd695909b52600 100644 (file)
@@ -1,5 +1,5 @@
 class role::file_store (
-  Optional[Array]  $nfs_mounts = ["cardano"],
+  Optional[Hash]  $nfs_mounts = {},
   Optional[String] $mountpoint = "/fichiers1",
 ) {
   include "base_installation"
@@ -7,7 +7,6 @@ class role::file_store (
   include "profile::fstab"
   include "profile::tools"
   include "profile::monitoring"
-  include "profile::kerberos::client"
   include "profile::wireguard"
 
   unless empty($mountpoint) {
@@ -19,19 +18,44 @@ class role::file_store (
       require                    => Mount[$mountpoint],
     }
 
-    $nfs_mounts.each |$nfs_mount| {
+    $nfs_mounts.each |$nfs_mount, $hosts| {
       file { "$mountpoint/$nfs_mount":
         ensure  => "directory",
         mode    => "0755",
         owner   => "nobody",
         group   => "nobody",
         require => Mount[$mountpoint],
-      } ->
-      nfs::server::export { "$mountpoint/$nfs_mount":
-        owner   => "nobody",
-        group   => "nobody",
-        ensure  => "present",
-        clients => "immae.eu(rw,secure,sync,all_squash,sec=krb5p)",
+      }
+
+      $hosts.each |$host_cn| {
+        $host = find_host($facts["ldapvar"]["other"], $host_cn)
+        if empty($host) {
+          fail("No host found for nfs")
+        } elsif has_key($host["vars"], "wireguard_ip") {
+          $clients = sprintf("%s%s",
+            join($host["vars"]["wireguard_ip"], "(rw,secure,sync,all_squash) "),
+            "(rw,secure,sync,all_squash)")
+          nfs::server::export { "$mountpoint/$nfs_mount":
+            owner   => "nobody",
+            group   => "nobody",
+            ensure  => "present",
+            clients => $clients,
+          }
+        } elsif has_key($host["vars"], "host") {
+          nfs::server::export { "$mountpoint/$nfs_mount":
+            owner   => "nobody",
+            group   => "nobody",
+            ensure  => "present",
+            clients => "${host[vars][host][0]}(rw,secure,sync,all_squash)",
+          }
+        } else {
+          nfs::server::export { "$mountpoint/$nfs_mount":
+            owner   => "nobody",
+            group   => "nobody",
+            ensure  => "present",
+            clients => "${host[vars][real_hostname][0]}(rw,secure,sync,all_squash)",
+          }
+        }
       }
     }
   }