diff --git a/.travis.yml b/.travis.yml index 87d702c..36a381a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,22 @@ --- sudo: false language: ruby +cache: bundler bundler_args: --without system_tests -script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" +before_install: rm Gemfile.lock || true +script: bundle exec rake validate lint spec matrix: fast_finish: true include: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.4.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.6.0" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION='~> 4.0' COVERAGE=yes STRICT_VARIABLES=yes + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#stable + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION='~> 3.0' FUTURE_PARSER=yes + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION='~> 3.0' + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION='~> 3.0' notifications: email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d840d8..a374c68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 2017-01-26 - 1.9.0 (Feature release) + +#### Bugfixes: + +- fix mountd thread number parameter for nfs server + +#### Features: + +- set specific version of nfs client packages with `package_ensure` +- allow client mounts to be defined in Hiera +- Ubuntu: support 16.04 + ## 2016-03-19 - 1.8.1 (Bugfix release) #### Bugfixes: diff --git a/Gemfile b/Gemfile index c3f05b2..df38e07 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,41 @@ -source 'https://rubygems.org' - -puppetversion = ENV.key?('PUPPET_GEM_VERSION') ? "#{ENV['PUPPET_GEM_VERSION']}" : ['>= 3.3'] -facterversion = ENV.key?('FACTER_GEM_VERSION') ? "#{ENV['FACTER_GEM_VERSION']}" : ['>= 1.7'] -gem 'puppet', puppetversion -gem 'puppetlabs_spec_helper', '>= 0.1.0' -gem 'puppet-lint', '>= 0.3.2' -gem 'facter', facterversion -gem 'rspec', '< 3.2.0' +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +def location_for(place, version = nil) + if place =~ /^((?:git|https?)[:@][^#]*)#(.*)/ + [version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, version, { :require => false }].compact + end +end + +gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false +gem 'puppet-lint', '>= 0.3.2', :require => false +gem 'rspec-puppet', '>= 2.3.2', :require => false +gem 'rspec-puppet-facts', :require => false +gem 'metadata-json-lint', :require => false # rubi <1.9 versus rake 11.0.0 workaround -gem 'rake', '< 11.0.0' +gem 'rake', '< 11.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') +gem 'json', '< 2.0.0', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') +gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0') + +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) + +# Only explicitly specify Facter/Hiera if a version has been specified. +# Otherwise it can lead to strange bundler behavior. If you are seeing weird +# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable +# to `1` and then run bundle install. +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] +gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] + + +# Evaluate Gemfile.local if it exists +if File.exists? "#{__FILE__}.local" + eval(File.read("#{__FILE__}.local"), binding) +end + +# Evaluate ~/.gemfile if it exists +if File.exists?(File.join(Dir.home, '.gemfile')) + eval(File.read(File.join(Dir.home, '.gemfile')), binding) +end diff --git a/README.md b/README.md index 9155a88..0b1368a 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -#nfs +# nfs -####Table of Contents +#### Table of Contents 1. [Overview - What is the nfs module?](#overview) 2. [Module Description - What does this module do?](#module-description) 3. [Setup - The basics of getting started with nfs](#setup) * [Simple mount an nfs share](#simple-mount-nfs-share) - * [NFSv3 server and client] (#nfsv3-server-and-client) - * [NFSv3 multiple exports, servers and multiple node] (#nfsv3-multiple-exports-servers-and-multiple-node) - * [NFSv4 Simple example] (#nfsv4-simple-example) - * [NFSv4 insanely overcomplicated reference] (#nfsv4-insanely-overcomplicated-reference) - * [A large number of clients] (#a-large-number-of-clients) + * [NFSv3 server and client](#nfsv3-server-and-client) + * [NFSv3 multiple exports, servers and multiple node](#nfsv3-multiple-exports-servers-and-multiple-node) + * [NFSv4 Simple example](#nfsv4-simple-example) + * [NFSv4 insanely overcomplicated reference](#nfsv4-insanely-overcomplicated-reference) + * [A large number of clients](#a-large-number-of-clients) 4. [Usage - The classes and defined types available for configuration](#usage) * [Class: nfs::server](#class-nfsserver) * [Defined Type: nfs::server::export](#defined-type-nfsserverexport) @@ -20,7 +20,7 @@ 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Contributing to the graphite module](#contributing) -##Overview +## Overview This module installs, configures and manages everything on NFS clients and servers. @@ -28,19 +28,19 @@ This module installs, configures and manages everything on NFS clients and serve [![Build Status](https://secure.travis-ci.org/echocat/puppet-nfs.png?branch=master)](https://travis-ci.org/echocat/puppet-nfs) [![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/echocat/nfs.svg)](https://forge.puppetlabs.com/echocat/nfs) -##Module Description +## Module Description This module can be used to simply mount nfs shares on a client or to configure your nfs servers. It can make use of storeconfigs on the puppetmaster to get its resources. -##Setup +## Setup **What nfs affects:** * packages/services/configuration files for NFS usage * can be used with puppet storage -###Simple mount nfs share +### Simple mount nfs share This example mounts a nfs share on the client, with NFSv3 @@ -54,7 +54,7 @@ include '::nfs::client' } ``` -###NFSv3 server and client +### NFSv3 server and client This will export /data/folder on the server and automagically mount it on client. You need storeconfigs/puppetdb for this to work. @@ -80,7 +80,7 @@ node client { } ``` -###NFSv3 multiple exports, servers and multiple node +### NFSv3 multiple exports, servers and multiple node ```puppet node server1 { @@ -148,7 +148,7 @@ node client { } ``` -###NFSv4 Simple example +### NFSv4 Simple example We use the `$::domain` fact for the Domain setting in `/etc/idmapd.conf`. For NFSv4 to work this has to be equal on servers and clients @@ -217,7 +217,7 @@ node client2 { } ``` -###NFSv4 insanely overcomplicated reference +### NFSv4 insanely overcomplicated reference Just to show you, how complex we can make things ;-) @@ -327,34 +327,38 @@ nfs::server::export {'/data': You can also give options to each host in a hash, and then use the stdlib keys() function to extract the client array from the hash: `mk_client_list(keys($client_hash), $client_hash, '')` -##Usage +## Usage -####Class: `nfs::server` +#### Class: `nfs::server` Set up NFS server and exports. NFSv3 and NFSv4 supported. **Parameters within `nfs::server`:** -#####`service_manage` (true) +##### `service_manage` (true) Should this class manage the services behind nfs? Set this to false if you are managing the service in another way (e.g. pacemaker). -#####`nfs_v4` (optional) +##### `package_ensure` (installed) + +Allow to update or set to a specific version the nfs server packages. + +##### `nfs_v4` (optional) NFSv4 support. Will set up automatic bind mounts to export root. Disabled by default. -#####`nfs_v4_export_root` (optional) +##### `nfs_v4_export_root` (optional) Export root, where we bind mount shares, default /export -#####`nfs_v4_idmap_domain` (optional) +##### `nfs_v4_idmap_domain` (optional) Domain setting for idmapd, must be the same across server and clients. Default is to use $domain fact. -#####`exports` (optional) +##### `exports` (optional) If set, this attribute will be used to construct nfs::server::export resources. You can use you ENC or hiera to @@ -367,7 +371,7 @@ nfs::server::exports: clients: '*(fsid=0,ro,insecure,async,all_squash,no_subtree_check,mountpoint=/mnt/something)' ``` -#####Examples +##### Examples ```puppet class { '::nfs::server': @@ -379,65 +383,66 @@ class { '::nfs::server': } ``` -####Defined Type: `nfs::server::export` +#### Defined Type: `nfs::server::export` Set up NFS export on the server (and stores data in configstore) **Parameters within `nfs::server::export`:** -#####`v3_export_name` (optional) +##### `v3_export_name` (optional) Default is `$name`. Usally you do not set it explicit. -#####`v4_export_name` (optional) +##### `v4_export_name` (optional) Default results from `$name`. Usally you do not set it explicit. -#####`ensure` (optional) +##### `ensure` (optional) Default is 'mounted' -#####`bind` (optional) +##### `bind` (optional) Default is 'rbind'. rbind or bind mounting of folders bindmounted into /export. Google it! **Following parameteres are propogated by to storeconfigs to clients** -#####`mount` (optional) +##### `mount` (optional) Default is undef. This means client mount path is the same as server export path. Directory where we want export mounted on client -#####`remounts` (optional) +##### `remounts` (optional) Default is false. -#####`atboot` (optional) +##### `atboot` (optional) Default is false. -#####`options` (optional) +##### `options` (optional) Default is '_netdev'. Don't remove that option, but feel free to add more. -#####`bindmount` (optional) +##### `bindmount` (optional) Default is undef. If set will mount share inside /srv (or overridden mount_root) and then bindmount to another directory elsewhere in the fs - for fanatics. -#####`nfstag` (optional) +##### `nfstag` (optional) Default is undef. Used to identify a catalog item for filtering by storeconfigs on clients. -#####`clients` (optional) +##### `clients` (optional) Default is 'localhost(ro)'. Copied directly into /etc/exports as a string, for simplicity. -#####`server` (optional) +##### `server` (optional) Default is `$::clientcert`. Used to specify a other ip/name for the client to connect to. Usefull in machines with multiple ip addresses or network interfaces -#####Example + +##### Example ```puppet ::nfs::server::export { '/media_library': @@ -446,27 +451,45 @@ Default is `$::clientcert`. Used to specify a other ip/name for the client to co } ``` -####Class: `nfs::client` +#### Class: `nfs::client` Set up NFS client and mounts. NFSv3 and NFSv4 supported. **Parameters within `nfs::client`:** -#####`nfs_v4` +##### `package_ensure` (installed) + +Allow to update or set to a specific version the nfs client packages. + +##### `nfs_v4` NFSv4 support. Disabled by default. -#####`nfs_v4_mount_root` +##### `nfs_v4_mount_root` Mount root, where we mount shares, default /srv -#####`nfs_v4_idmap_domain` +##### `nfs_v4_idmap_domain` Domain setting for idmapd, must be the same across server and clients. Default is to use $::domain fact. -#####Example +##### `mounts` (optional) + +If set, this attribute will be used to construct nfs::client::mount resources. +You can use you ENC or hiera to provide the hash of nfs::client::mount +resources definitions: + +```hiera +nfs::client::mounts: + /mnt/test: + ensure: 'mounted' + server: '192.0.2.100' + share: '/export/data' +``` + +##### Example ```puppet class { '::nfs::client': @@ -477,79 +500,66 @@ class { '::nfs::client': } ``` -####Defined Type: `nfs::client::mount` +#### Defined Type: `nfs::client::mount` Set up NFS mount on client. **Parameters within `nfs::client::mount`:** -#####`server` +##### `server` FQDN or IP of the NFS server. -#####`share` +##### `share` Name of share to be mounted. -#####`ensure` (optional) +##### `ensure` (optional) Default is 'mounted'. -#####`mount` (optional) +##### `mount` (optional) Default is `$title` of defined type. Defines mountpoint of the share on the client. -#####`remounts` (optional) +##### `remounts` (optional) Default is false. -#####`atboot` (optional) +##### `atboot` (optional) Default is false. -#####`options` (optional) +##### `options` (optional) Default is '_netdev'. Don't remove that option, but feel free to add more. -#####`bindmount` (optional) +##### `bindmount` (optional) Default is undef. If set will mount share inside /srv (or overridden mount_root) and then bindmount to another directory elsewhere in the fs - for fanatics. -#####`nfstag` (optional) +##### `nfstag` (optional) Default is undef. Used to identify a catalog item for filtering by storeconfigs on clients. -#####`owner` (optional) +##### `owner` (optional) Default is 'root'. Sets owner of mountpoint directory. This is applied to the directory on every run, which means it is used both on the base mountpoint creation when unmounted, and also once mounted on the target NFS server and thus all servers accessing the same share. - -#####`group` (optional) +##### `group` (optional) Default is `root`. Sets group of mountpoint directory. This is applied to the directory on every run, which means it is used both on the base mountpoint creation when unmounted, and also once mounted on the target NFS server and thus all servers accessing the same share. - -#####`perm` (optional) +##### `perm` (optional) Default is '0755'. Sets mode of mountpoint directory. This has changed from previous versons which used '0777' (world writable). This is applied to the directory on every run, which means it is used both on the base mountpoint creation when unmounted, and also once mounted on the target NFS server and thus all servers accessing the same share. - -##Requirements +## Requirements If you want to have the full potential of this module its recommend to have storeconfigs enabled. -###Modules needed: - -* stdlib by puppetlabs -* concat by puppetlabs - -###Software versions needed: - -* facter > 1.6.2 -* puppet > 2.6.2 - -##Limitations +## Limitations ##Contributing diff --git a/Rakefile b/Rakefile index c35cebb..c49986c 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_class_parameter_defaults') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] desc "Validate manifests, templates, and ruby files in lib." task :validate do @@ -24,4 +24,4 @@ end task :test => [:spec, :lint] -task :default => :test \ No newline at end of file +task :default => :test diff --git a/manifests/client.pp b/manifests/client.pp index 7a8e3d0..7653b2a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -5,6 +5,10 @@ # # === Parameters # +# [package_ensure] +# Allow to update or set to a specific version the nfs client packages +# Default to installed. +# # [nfs_v4] # NFSv4 support. # Disabled by default. @@ -29,9 +33,11 @@ # } class nfs::client ( + $package_ensure = $::nfs::params::client_package_ensure, $nfs_v4 = $::nfs::params::nfs_v4, $nfs_v4_mount_root = $::nfs::params::nfs_v4_mount_root, - $nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain + $nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain, + $mounts = undef ) inherits nfs::params { validate_bool($nfs_v4) @@ -50,4 +56,8 @@ } } + if $mounts { + create_resources(nfs::client::mount, $mounts) + } + } diff --git a/manifests/client/debian/install.pp b/manifests/client/debian/install.pp index 775db36..16712a8 100644 --- a/manifests/client/debian/install.pp +++ b/manifests/client/debian/install.pp @@ -1,11 +1,11 @@ class nfs::client::debian::install { package { 'rpcbind': - ensure => installed, + ensure => $::nfs::client::package_ensure, } package { ['nfs-common', 'nfs4-acl-tools']: - ensure => installed, + ensure => $::nfs::client::package_ensure, } } diff --git a/manifests/client/gentoo/install.pp b/manifests/client/gentoo/install.pp index ca63d2f..e0432dd 100644 --- a/manifests/client/gentoo/install.pp +++ b/manifests/client/gentoo/install.pp @@ -1,6 +1,6 @@ class nfs::client::gentoo::install { package { ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap']: - ensure => installed, + ensure => $::nfs::client::package_ensure, } } diff --git a/manifests/client/mount.pp b/manifests/client/mount.pp index 6bd63a0..e3efced 100644 --- a/manifests/client/mount.pp +++ b/manifests/client/mount.pp @@ -23,10 +23,10 @@ $_nfs4_mount = $mount } - nfs::mkdir{ $_nfs4_mount: - owner => $owner, - group => $group, - perm => $perm; + nfs::mkdir { $_nfs4_mount: + owner => $owner, + group => $group, + perm => $perm; } mount {"shared ${server}:${share} by ${::clientcert} on ${_nfs4_mount}": diff --git a/manifests/client/redhat/install.pp b/manifests/client/redhat/install.pp index 07df9cd..d3d82a6 100644 --- a/manifests/client/redhat/install.pp +++ b/manifests/client/redhat/install.pp @@ -7,16 +7,16 @@ before => Class['nfs::client::redhat::configure'] } package { 'nfs-utils': - ensure => present, + ensure => $::nfs::client::package_ensure, } if $::nfs::client::redhat::params::osmajor == 6 or $::nfs::client::redhat::params::osmajor == 7 { package {'rpcbind': - ensure => present, + ensure => $::nfs::client::package_ensure, } } elsif $::nfs::client::redhat::params::osmajor == 5 { package { 'portmap': - ensure => present, + ensure => $::nfs::client::package_ensure, } } } diff --git a/manifests/client/ubuntu/install.pp b/manifests/client/ubuntu/install.pp index 671db42..90001d1 100644 --- a/manifests/client/ubuntu/install.pp +++ b/manifests/client/ubuntu/install.pp @@ -1,11 +1,11 @@ class nfs::client::ubuntu::install { package { 'rpcbind': - ensure => installed, + ensure => $::nfs::client::package_ensure, } package { ['nfs-common', 'nfs4-acl-tools']: - ensure => installed, + ensure => $::nfs::client::package_ensure, } } diff --git a/manifests/client/ubuntu/service.pp b/manifests/client/ubuntu/service.pp index bea31c8..072864e 100644 --- a/manifests/client/ubuntu/service.pp +++ b/manifests/client/ubuntu/service.pp @@ -7,10 +7,12 @@ } if $nfs::client::ubuntu::nfs_v4 { - service { 'idmapd': - ensure => running, - enable => true, - subscribe => Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'], + if versioncmp($::lsbdistrelease, '16.04') < 0 { + service { 'idmapd': + ensure => running, + enable => true, + subscribe => Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'], + } } } else { service { 'idmapd': diff --git a/manifests/params.pp b/manifests/params.pp index 3a23757..6760bf4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,4 +1,6 @@ class nfs::params ( + $client_package_ensure = 'installed', + $server_package_ensure = 'installed', $nfs_v4 = false, $nfs_v4_export_root = '/export', $nfs_v4_export_root_clients = "*.${::domain}(ro,fsid=root,insecure,no_subtree_check,async,root_squash)", diff --git a/manifests/server.pp b/manifests/server.pp index 748a12a..8fdaf4b 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -5,6 +5,10 @@ # # === Parameters # +# [package_ensure] +# Allow to update or set to a specific version the nfs server packages +# Default to installed. +# # [nfs_v4] # NFSv4 support. Will set up automatic bind mounts to export root. # Disabled by default. @@ -33,6 +37,7 @@ # } class nfs::server ( + $package_ensure = $::nfs::params::server_package_ensure, $nfs_v4 = $nfs::params::nfs_v4, $nfs_v4_export_root = $nfs::params::nfs_v4_export_root, $nfs_v4_export_root_clients = $nfs::params::nfs_v4_export_root_clients, @@ -49,7 +54,7 @@ $nfs_v4_root_export_tag = undef, # $mountd_port = undef, - $mountd_threads = 1, + $mountd_threads = undef, # $exports = undef, ) inherits nfs::params { diff --git a/manifests/server/darwin.pp b/manifests/server/darwin.pp index 73fedc5..17981e0 100644 --- a/manifests/server/darwin.pp +++ b/manifests/server/darwin.pp @@ -2,7 +2,7 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1, + $mountd_threads = undef, $service_manage = true, ) { fail('NFS server is not supported on Darwin') diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index 103a391..1b20586 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -3,7 +3,7 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1, + $mountd_threads = 8, $service_manage = true, ) { @@ -16,10 +16,11 @@ if ($mountd_port != undef){ file_line { 'rpc-mount-options': - ensure => present, - path => '/etc/default/nfs-kernel-server', - line => "RPCMOUNTDOPTS=\"--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}\"", - match => '^#?RPCMOUNTDOPTS'; + ensure => present, + path => '/etc/default/nfs-kernel-server', + line => "RPCMOUNTDOPTS=\"--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}\"", + match => '^#?RPCMOUNTDOPTS', + require => Package['nfs-kernel-server']; } if $service_manage { diff --git a/manifests/server/debian/install.pp b/manifests/server/debian/install.pp index 5fa1c73..5b736f8 100644 --- a/manifests/server/debian/install.pp +++ b/manifests/server/debian/install.pp @@ -1,7 +1,7 @@ class nfs::server::debian::install { package { 'nfs-kernel-server': - ensure => installed + ensure => $::nfs::server::package_ensure } } diff --git a/manifests/server/gentoo.pp b/manifests/server/gentoo.pp index 2bc46b1..1a6a26f 100644 --- a/manifests/server/gentoo.pp +++ b/manifests/server/gentoo.pp @@ -3,7 +3,7 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1, + $mountd_threads = undef, $service_manage = true, ) { @@ -18,6 +18,10 @@ fail('setting the mountd port currently not supported on Gentoo') } + if ($mountd_threads != undef){ + fail('setting the mountd thread number currently not supported on Gentoo') + } + include nfs::server::gentoo::install, nfs::server::gentoo::service } diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index a5bca31..9562191 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -1,33 +1,50 @@ -class nfs::server::redhat( +class nfs::server::redhat ( $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1, - $service_manage = true, -) { + $mountd_threads = undef, + $service_manage = true,) { + + if !defined(Class['nfs::client::redhat']) { + class { 'nfs::client::redhat': + nfs_v4 => $nfs_v4, + nfs_v4_idmap_domain => $nfs_v4_idmap_domain, + } + } + if $::operatingsystemmajrelease and $::operatingsystemmajrelease =~ /^7/ { $service_name = 'nfs-server' + } else { $service_name = 'nfs' + } - if !defined(Class['nfs::client::redhat']) { - class{ 'nfs::client::redhat': - nfs_v4 => $nfs_v4, - nfs_v4_idmap_domain => $nfs_v4_idmap_domain, + if ($mountd_port != undef) { + file_line { 'rpc-mount-options-port': + ensure => present, + path => '/etc/sysconfig/nfs', + line => "MOUNTD_PORT=${mountd_port}", + match => '^#?MOUNTD_PORT', + require => Package['nfs-utils']; + } + + if $service_manage { + File_line['rpc-mount-options-port'] ~> Service[$service_name] } } - if ($mountd_port != undef){ - file_line { 'rpc-mount-options': - ensure => present, - path => '/etc/sysconfig/nfs', - line => "MOUNTD_PORT=${mountd_port}", - match => '^#?MOUNTD_PORT'; + if ($mountd_threads != undef) { + file_line { 'rpc-mount-options-threads': + ensure => present, + path => '/etc/sysconfig/nfs', + line => "RPCNFSDCOUNT=${mountd_threads}", + match => '^#?RPCNFSDCOUNT=', + require => Package['nfs-utils']; } if $service_manage { - File_line['rpc-mount-options'] ~> Service[$service_name] + File_line['rpc-mount-options-threads'] ~> Service[$service_name] } } diff --git a/manifests/server/redhat/install.pp b/manifests/server/redhat/install.pp index 6975836..598749c 100644 --- a/manifests/server/redhat/install.pp +++ b/manifests/server/redhat/install.pp @@ -1,7 +1,7 @@ class nfs::server::redhat::install { package { 'nfs4-acl-tools': - ensure => installed, + ensure => $::nfs::server::package_ensure, } } diff --git a/manifests/server/ubuntu.pp b/manifests/server/ubuntu.pp index 698e38b..d222bfc 100644 --- a/manifests/server/ubuntu.pp +++ b/manifests/server/ubuntu.pp @@ -3,7 +3,7 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1, + $mountd_threads = 8, $service_manage = true, ) { @@ -16,10 +16,11 @@ if ($mountd_port != undef){ file_line { 'rpc-mount-options': - ensure => present, - path => '/etc/default/nfs-kernel-server', - line => "RPCMOUNTDOPTS=--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}", - match => '^#?RPCMOUNTDOPTS'; + ensure => present, + path => '/etc/default/nfs-kernel-server', + line => "RPCMOUNTDOPTS=--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}", + match => '^#?RPCMOUNTDOPTS', + require => Package['nfs-kernel-server']; } if $service_manage { diff --git a/manifests/server/ubuntu/install.pp b/manifests/server/ubuntu/install.pp index 83a7629..47826bc 100644 --- a/manifests/server/ubuntu/install.pp +++ b/manifests/server/ubuntu/install.pp @@ -1,7 +1,7 @@ class nfs::server::ubuntu::install { package { 'nfs-kernel-server': - ensure => installed + ensure => $::nfs::server::package_ensure } } diff --git a/metadata.json b/metadata.json index 7fe1ff5..dbec2d4 100644 --- a/metadata.json +++ b/metadata.json @@ -37,7 +37,8 @@ "operatingsystemrelease": [ "10.04", "12.04", - "14.04" + "14.04", + "16.04" ] }, { @@ -60,8 +61,8 @@ } ], "name": "echocat-nfs", - "version": "1.8.1", - "source": "git clone https://github.com/echocat/puppet-nfs.git", + "version": "1.9.0", + "source": "https://github.com/echocat/puppet-nfs.git", "author": "echocat", "license": "Apache-2.0", "summary": "Installs and configures NFS server and clients", @@ -69,6 +70,6 @@ "issues_url": "https://github.com/echocat/puppet-nfs/issues", "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 4.8.0 < 5.0.0"}, - {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 < 2.0.0"} + {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 < 3.0.0"} ] } diff --git a/spec/classes/client_debian_spec.rb b/spec/classes/client_debian_spec.rb index bcfa3a2..1c82e86 100644 --- a/spec/classes/client_debian_spec.rb +++ b/spec/classes/client_debian_spec.rb @@ -1,6 +1,13 @@ require 'spec_helper' describe 'nfs::client::debian' do + let(:facts) do + facts + end + let :pre_condition do + 'include ::nfs::client' + end + it do should contain_class('nfs::client::debian::install') should contain_class('nfs::client::debian::configure') diff --git a/spec/classes/client_gentoo_spec.rb b/spec/classes/client_gentoo_spec.rb index e397118..1084241 100644 --- a/spec/classes/client_gentoo_spec.rb +++ b/spec/classes/client_gentoo_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe 'nfs::client::gentoo' do + let(:params) {{ :package_ensure => 'installed' }} + it do should contain_class('nfs::client::gentoo') should contain_class('nfs::client::gentoo::install') diff --git a/spec/classes/client_redhat_spec.rb b/spec/classes/client_redhat_spec.rb index 23418b3..e0740ce 100644 --- a/spec/classes/client_redhat_spec.rb +++ b/spec/classes/client_redhat_spec.rb @@ -1,5 +1,8 @@ require 'spec_helper' describe 'nfs::client::redhat' do + + let(:params) {{ :package_ensure => 'installed' }} + context "operatingsystemrelease => 7.0" do let(:facts) { {:operatingsystemrelease => '7.0' } } it do diff --git a/spec/classes/client_ubuntu_spec.rb b/spec/classes/client_ubuntu_spec.rb index 0140614..d782a9c 100644 --- a/spec/classes/client_ubuntu_spec.rb +++ b/spec/classes/client_ubuntu_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe 'nfs::client::ubuntu' do + let(:params) {{ :package_ensure => 'installed' }} + it do should contain_class('nfs::client::ubuntu::install') should contain_class('nfs::client::ubuntu::configure') diff --git a/spec/classes/server_debian_spec.rb b/spec/classes/server_debian_spec.rb index 04a8f85..81a15ba 100644 --- a/spec/classes/server_debian_spec.rb +++ b/spec/classes/server_debian_spec.rb @@ -12,14 +12,14 @@ it do should contain_service('idmapd').with( 'ensure' => 'running' ) end - end - context "mountd params set" do + + context "mountd params set port" do let(:params) {{ :mountd_port => '4711' }} it do should contain_file_line('rpc-mount-options') #.with( 'ensure' => 'present' ) end - end + end diff --git a/spec/classes/server_redhat_spec.rb b/spec/classes/server_redhat_spec.rb index f41b119..dc706e3 100644 --- a/spec/classes/server_redhat_spec.rb +++ b/spec/classes/server_redhat_spec.rb @@ -23,10 +23,17 @@ end end - context "mountd params set" do + context "mountd params set port" do let(:params) {{ :mountd_port => '4711' }} it do - should contain_file_line('rpc-mount-options') #.with( 'ensure' => 'present' ) + should contain_file_line('rpc-mount-options-port') #.with( 'ensure' => 'present' ) + end + end + + context "mountd params set threads" do + let(:params) {{ :mountd_threads => '11' }} + it do + should contain_file_line('rpc-mount-options-threads') #.with( 'ensure' => 'present' ) end end end diff --git a/spec/classes/server_ubuntu_spec.rb b/spec/classes/server_ubuntu_spec.rb index 653bdec..aaa1b84 100644 --- a/spec/classes/server_ubuntu_spec.rb +++ b/spec/classes/server_ubuntu_spec.rb @@ -12,14 +12,13 @@ it do should contain_service('idmapd').with( 'ensure' => 'running' ) end - end - context "mountd params set" do + + context "mountd params set port" do let(:params) {{ :mountd_port => '4711' }} it do should contain_file_line('rpc-mount-options') #.with( 'ensure' => 'present' ) end - end -end +end