nfs: Merge from parameterize branch

This commit is contained in:
Ossi Salmi 2016-04-18 15:13:58 +03:00
parent f619236878
commit bd5ccf4211
3 changed files with 100 additions and 28 deletions

View file

@ -1,4 +1,3 @@
# Install NFS client.
#
class nfs::client {
@ -13,13 +12,32 @@ class nfs::client {
},
}
if $::operatingsystem == "Fedora" and $::operatingsystemrelease >= 16 {
case $::operatingsystem {
"fedora": {
# https://bugzilla.redhat.com/show_bug.cgi?id=692008
service { "NetworkManager-wait-online":
ensure => stopped,
enable => true,
}
}
"ubuntu": {
file { "/etc/modprobe.d/lockd.conf":
ensure => present,
mode => "0644",
owner => "root",
group => "root",
content => "options lockd nlm_tcpport=4001 nlm_udpport=4001\n",
before => Package["nfs-utils"],
}
augeas { "set-nfs-common":
context => "/files/etc/default/nfs-common",
changes => "set STATDOPTS '\"--port 4000\"'",
notify => Service["nfslock"],
require => Package["nfs-utils"],
}
}
default: { }
}
service { "nfslock":
ensure => running,
@ -45,7 +63,21 @@ class nfs::client {
# Install and configure NFS server.
#
class nfs::server {
# === Parameters
#
# $servers:
# Number of nfs server processes to be started. Defaults to 8.
#
# $versions:
# Array of NFS versions to enable. Defaults to [ "3" ].
#
class nfs::server(
$servers="8",
$versions=["3"],
) {
$default_versions = [ "2", "3", "4" ]
$disable_versions = inline_template('<%= (@default_versions - @versions).map { |v| "-N %s" % v }.join(" ") %>')
require nfs::client
@ -58,18 +90,36 @@ class nfs::server {
mode => "0644",
owner => "root",
group => "root",
require => Package["nfs-utils"],
notify => Exec["exportfs"],
}
case $::operatingsystem {
"centos","redhat","fedora": {
file { "/etc/sysconfig/nfs":
ensure => present,
content => template("nfs/nfs.sysconfig.erb"),
mode => "0644",
owner => "root",
group => "root",
content => template("nfs/nfs.sysconfig.erb"),
notify => Service["nfs"],
}
}
"ubuntu": {
package { "nfs-kernel-server":
ensure => installed,
}
file { "/etc/default/nfs-kernel-server":
ensure => present,
mode => "0644",
owner => "root",
group => "root",
content => template("nfs/nfs-kernel-server.erb"),
require => Package["nfs-kernel-server"],
notify => Service["nfs"],
}
}
default: { }
}
service { "nfs":
ensure => running,
@ -78,11 +128,11 @@ class nfs::server {
/^([1-9]|1[0-5])$/ => "nfs",
default => "nfs-server",
},
"ubuntu" => "nfs-kernel-server",
default => "nfs",
},
enable => true,
hasstatus => true,
require => Service["nfslock"],
}
exec { "exportfs":

View file

@ -0,0 +1,22 @@
# Number of servers to start up
RPCNFSDCOUNT=<%= @servers %>
# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
RPCMOUNTDOPTS="--manage-gids --port 4002 <%= @disable_versions %>"
# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""
# Options for rpc.svcgssd.
RPCSVCGSSDOPTS=""
# Options for rpc.nfsd.
RPCNFSDOPTS="<%= @disable_versions %>"

View file

@ -26,20 +26,20 @@ LOCKD_UDPPORT=4001
# Turn off v2 and v3 protocol support
#RPCNFSDARGS="-N 2 -N 3"
# Turn off v4 protocol support
RPCNFSDARGS="-N 4"
RPCNFSDARGS="<%= @disable_versions %>"
# Number of nfs server processes to be started.
# The default is 8.
RPCNFSDCOUNT=64
RPCNFSDCOUNT=<%= @servers %>
# Stop the nfsd module from being pre-loaded
#NFSD_MODULE="noload"
#
#
<% if @operatingsystem == 'Fedora' -%>
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
RPCMOUNTDOPTS="--no-nfs-version 4 -p 4002"
RPCMOUNTDOPTS="<%= @disable_versions %> -p 4002"
<% else -%>
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
RPCMOUNTDOPTS="--no-nfs-version 4"
RPCMOUNTDOPTS="<%= @disable_versions %>"
# Port rpc.mountd should listen on.
MOUNTD_PORT=4002
<% end -%>