X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Frole%2Fmanifests%2Ffile_store.pp;fp=modules%2Frole%2Fmanifests%2Ffile_store.pp;h=d1f6a6794a6ccd2ea3448bcf30bd695909b52600;hb=6667f52e8017065c9b5f14c8025458b38029a800;hp=0000000000000000000000000000000000000000;hpb=19c467dccfd00193a66f1341f068987da7bca14b;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/modules/role/manifests/file_store.pp b/modules/role/manifests/file_store.pp new file mode 100644 index 0000000..d1f6a67 --- /dev/null +++ b/modules/role/manifests/file_store.pp @@ -0,0 +1,62 @@ +class role::file_store ( + Optional[Hash] $nfs_mounts = {}, + Optional[String] $mountpoint = "/fichiers1", +) { + include "base_installation" + + include "profile::fstab" + include "profile::tools" + include "profile::monitoring" + include "profile::wireguard" + + unless empty($mountpoint) { + class { "::nfs": + server_enabled => true, + nfs_v4 => true, + nfs_v4_export_root => '/exports', + nfs_v4_export_root_clients => 'localhost(rw)', + require => Mount[$mountpoint], + } + + $nfs_mounts.each |$nfs_mount, $hosts| { + file { "$mountpoint/$nfs_mount": + ensure => "directory", + mode => "0755", + owner => "nobody", + group => "nobody", + require => Mount[$mountpoint], + } + + $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)", + } + } + } + } + } +}