Puppet Class: nfs_server
- Inherits:
- nfs_server::params
- Defined in:
- manifests/init.pp
Overview
Nfs_server
Support for NFSv4 kernel server on Linux
The main source of configuration is the share_hash
variable
which is responsible for creating and exporting each shared directory. It
has the form:
share_hash => {
"directory_name" => {
client => client(share_option1,...,share_optionN) client(share_option1,...,share_optionN),
owner => OWNER_OF_SHARE_DIR,
group => GROUP_OF_SHARE_DIR,
mode => MODE_OF_SHARE_DIR,
}
}
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'manifests/init.pp', line 47
class nfs_server(
String $package = $nfs_server::params::package,
Boolean $manage_package = true,
Enum[present,absent] $ensure_package = present,
Hash $share_hash = {},
String $default_owner = $nfs_server::params::default_owner,
String $default_group = $nfs_server::params::default_group,
String $default_mode = "0770",
Boolean $manage_service = true,
String $service = $nfs_server::params::service,
Enum[running,stopped] $service_ensure = running,
Boolean $service_enable = true,
String $exports = "/etc/exports",
) inherits nfs_server::params {
if $manage_package {
package { $package:
ensure => $ensure_package,
}
}
file { "/etc/exports":
ensure => file,
owner => "root",
group => "root",
mode => "0644",
}
$share_hash.each |$share_dir, $opts| {
# manage the shared directory with puppet unless we were told not to (it
# could be a mounted elsewhere)
if pick($opts["manage_dir"],true) {
$mode = pick($opts['mode'], $default_mode)
file { $share_dir:
ensure => directory,
owner => pick($opts['owner'], $default_owner),
group => pick($opts['group'], $default_group),
mode => $mode,
}
}
# munge the line for /etc/exports
file_line { "exports_for_${share_dir}":
ensure => present,
path => $exports,
line => "${share_dir}\t${opts['client']}",
match => "^${share_dir}\t",
notify => Exec["reload_nfs_exports"],
}
}
if $manage_service {
$service_require = Service[$service]
service { $service:
ensure => $service_ensure,
enable => $service_enable,
require => Package[$package],
}
} else {
$service_require = undef
}
exec { "reload_nfs_exports":
command => "exportfs -a",
path => ["/usr/sbin", "/sbin"],
refreshonly => true,
require => $service_require,
}
}
|