diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-08-18 19:45:20 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-11-11 11:02:43 +0100 |
commit | da476aeb6d365769de4956796b25255086d94cb7 (patch) | |
tree | df138b89be182b1249b78a79f908b478c99c6dd0 /modules | |
parent | 97e618665a5df3c5c209620ea1c8cd36d9747ae3 (diff) | |
download | Puppet-da476aeb6d365769de4956796b25255086d94cb7.tar.gz Puppet-da476aeb6d365769de4956796b25255086d94cb7.tar.zst Puppet-da476aeb6d365769de4956796b25255086d94cb7.zip |
Group hosts in single export linefile_store
Diffstat (limited to 'modules')
-rw-r--r-- | modules/role/manifests/file_store.pp | 36 | ||||
-rw-r--r-- | modules/role/templates/file_store/nfs_clients.erb | 12 |
2 files changed, 18 insertions, 30 deletions
diff --git a/modules/role/manifests/file_store.pp b/modules/role/manifests/file_store.pp index d1f6a67..665a32b 100644 --- a/modules/role/manifests/file_store.pp +++ b/modules/role/manifests/file_store.pp | |||
@@ -26,36 +26,12 @@ class role::file_store ( | |||
26 | group => "nobody", | 26 | group => "nobody", |
27 | require => Mount[$mountpoint], | 27 | require => Mount[$mountpoint], |
28 | } | 28 | } |
29 | 29 | -> | |
30 | $hosts.each |$host_cn| { | 30 | nfs::server::export { "$mountpoint/$nfs_mount": |
31 | $host = find_host($facts["ldapvar"]["other"], $host_cn) | 31 | owner => "nobody", |
32 | if empty($host) { | 32 | group => "nobody", |
33 | fail("No host found for nfs") | 33 | ensure => "present", |
34 | } elsif has_key($host["vars"], "wireguard_ip") { | 34 | clients => template("role/file_store/nfs_clients.erb"), |
35 | $clients = sprintf("%s%s", | ||
36 | join($host["vars"]["wireguard_ip"], "(rw,secure,sync,all_squash) "), | ||
37 | "(rw,secure,sync,all_squash)") | ||
38 | nfs::server::export { "$mountpoint/$nfs_mount": | ||
39 | owner => "nobody", | ||
40 | group => "nobody", | ||
41 | ensure => "present", | ||
42 | clients => $clients, | ||
43 | } | ||
44 | } elsif has_key($host["vars"], "host") { | ||
45 | nfs::server::export { "$mountpoint/$nfs_mount": | ||
46 | owner => "nobody", | ||
47 | group => "nobody", | ||
48 | ensure => "present", | ||
49 | clients => "${host[vars][host][0]}(rw,secure,sync,all_squash)", | ||
50 | } | ||
51 | } else { | ||
52 | nfs::server::export { "$mountpoint/$nfs_mount": | ||
53 | owner => "nobody", | ||
54 | group => "nobody", | ||
55 | ensure => "present", | ||
56 | clients => "${host[vars][real_hostname][0]}(rw,secure,sync,all_squash)", | ||
57 | } | ||
58 | } | ||
59 | } | 35 | } |
60 | } | 36 | } |
61 | } | 37 | } |
diff --git a/modules/role/templates/file_store/nfs_clients.erb b/modules/role/templates/file_store/nfs_clients.erb new file mode 100644 index 0000000..0d8a295 --- /dev/null +++ b/modules/role/templates/file_store/nfs_clients.erb | |||
@@ -0,0 +1,12 @@ | |||
1 | <%= @hosts.flat_map do |host_cn, config| | ||
2 | host = scope.function_find_host([@facts["ldapvar"]["other"], host_cn]) | ||
3 | if host.nil? | ||
4 | [host_cn] | ||
5 | elsif !host["vars"]["wireguard_ip"].nil? | ||
6 | host["vars"]["wireguard_ip"] | ||
7 | elsif !host["vars"]["host"].nil? | ||
8 | host["vars"]["host"] | ||
9 | else | ||
10 | host["vars"]["real_hostname"] | ||
11 | end.map { |h| h + config } | ||
12 | end.join(" ") -%> | ||