diff --git a/.fixtures.yml b/.fixtures.yml index d83a795..7b784fa 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,5 +6,10 @@ fixtures: concat: repo: "git://github.com/puppetlabs/puppetlabs-concat.git" ref: "1.1.1" + # transitive requirement of augeasproviders_shellvar + augeasproviders_core: + repo: "git://github.com/hercules-team/augeasproviders_core.git" + augeasproviders_shellvar: + repo: "git://github.com/hercules-team/augeasproviders_shellvar.git" symlinks: "nfs": "#{source_dir}" diff --git a/manifests/client/debian/install.pp b/manifests/client/debian/install.pp index 1c00d3f..3ac6d78 100644 --- a/manifests/client/debian/install.pp +++ b/manifests/client/debian/install.pp @@ -4,7 +4,7 @@ ensure => installed, } - Package['rpcbind'] -> Service ['rpcbind'] + Package['rpcbind'] -> Service['rpcbind'] package { ['nfs-common', 'nfs4-acl-tools']: diff --git a/manifests/client/redhat/service.pp b/manifests/client/redhat/service.pp index 0e4ea1b..36846f7 100644 --- a/manifests/client/redhat/service.pp +++ b/manifests/client/redhat/service.pp @@ -7,6 +7,8 @@ require => Class['nfs::client::redhat::configure'] } +# lint:ignore:selector_inside_resource would not add much to readability + service {'nfslock': ensure => running, name => $::nfs::client::redhat::params::osmajor ? { @@ -32,6 +34,8 @@ } } +# lint:endignore + if $::nfs::client::redhat::params::osmajor == 6 or $::nfs::client::redhat::params::osmajor == 7 { service {'rpcbind': ensure => running, diff --git a/manifests/server.pp b/manifests/server.pp index e2710ac..0e5712c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -40,12 +40,17 @@ $nfs_v4_root_export_atboot = false, $nfs_v4_root_export_options = '_netdev', $nfs_v4_root_export_bindmount = undef, - $nfs_v4_root_export_tag = undef + $nfs_v4_root_export_tag = undef, + # + $mountd_port = undef, + $mountd_threads = 1 ) inherits nfs::params { class { "nfs::server::${::nfs::params::osfamily}": nfs_v4 => $nfs_v4, nfs_v4_idmap_domain => $nfs_v4_idmap_domain, + mountd_port => $mountd_port, + mountd_threads => $mountd_threads, } include nfs::server::configure diff --git a/manifests/server/configure.pp b/manifests/server/configure.pp index 115490b..9150499 100644 --- a/manifests/server/configure.pp +++ b/manifests/server/configure.pp @@ -10,7 +10,7 @@ 'nfs_exports_header': target => '/etc/exports', content => "# This file is configured through the nfs::server puppet module\n", - order => 01; + order => '01'; } if $nfs::server::nfs_v4 == true { diff --git a/manifests/server/darwin.pp b/manifests/server/darwin.pp index b779442..f6181ae 100644 --- a/manifests/server/darwin.pp +++ b/manifests/server/darwin.pp @@ -1,6 +1,8 @@ class nfs::server::darwin( $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4_idmap_domain = undef, + $mountd_port = undef, + $mountd_threads = 1 ) { fail('NFS server is not supported on Darwin') } diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index 3ae0aaf..bd5d32f 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -1,7 +1,9 @@ # Debian specifix stuff class nfs::server::debian( - $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef, + $mountd_port = undef, + $mountd_threads = 1 ) { if !defined(Class['nfs::client::debian']) { @@ -11,5 +13,15 @@ } } + if ($mountd_port != undef){ + shellvar { 'rpc-mount-options': + ensure => present, + target => '/etc/default/nfs-kernel-server', + variable => 'RPCMOUNTDOPTS', + value => "--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}", + notify => Service['nfs-kernel-server'], + } + } + include nfs::server::debian::install, nfs::server::debian::service } diff --git a/manifests/server/gentoo.pp b/manifests/server/gentoo.pp index bb176fd..a74a501 100644 --- a/manifests/server/gentoo.pp +++ b/manifests/server/gentoo.pp @@ -1,7 +1,9 @@ # Gentoo specifix stuff class nfs::server::gentoo( $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4_idmap_domain = undef, + $mountd_port = undef, + $mountd_threads = 1 ) { if !defined(Class['nfs::client::gentoo']) { @@ -11,6 +13,10 @@ } } + if ($mountd_port != undef){ + fail('setting the mountd port currently not supported on Gentoo') + } + include nfs::server::gentoo::install, nfs::server::gentoo::service } diff --git a/manifests/server/nfs_v4/configure.pp b/manifests/server/nfs_v4/configure.pp index 154d0bb..0f5501a 100644 --- a/manifests/server/nfs_v4/configure.pp +++ b/manifests/server/nfs_v4/configure.pp @@ -4,7 +4,7 @@ 'nfs_exports_root': target => '/etc/exports', content => "${nfs::server::nfs_v4_export_root} ${nfs::server::nfs_v4_export_root_clients}\n", - order => 02 + order => '02' } file { $nfs::server::nfs_v4_export_root: diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index 5053107..dd26d4b 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -1,6 +1,8 @@ class nfs::server::redhat( - $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef, + $mountd_port = undef, + $mountd_threads = 1 ) { if !defined(Class['nfs::client::redhat']) { @@ -10,6 +12,10 @@ } } + if ($mountd_port != undef){ + fail('Setting mountd port currently not supported on RedHat') + } + include nfs::server::redhat::install, nfs::server::redhat::service diff --git a/metadata.json b/metadata.json index 00b9098..4099244 100644 --- a/metadata.json +++ b/metadata.json @@ -36,6 +36,7 @@ "issues_url": "https://github.com/echocat/puppet-nfs/issues", "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"}, - {"name":"puppetlabs/concat","version_requirement":">= 1.1.1"} + {"name":"puppetlabs/concat","version_requirement":">= 1.1.1"}, + {"name":"herculesteam/augeasproviders_shellvar","version_requirement":">= 2.1.0"} ] } diff --git a/spec/classes/client_redhat_spec.rb b/spec/classes/client_redhat_spec.rb index 5d89238..a99357a 100644 --- a/spec/classes/client_redhat_spec.rb +++ b/spec/classes/client_redhat_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'nfs::client::redhat' do context "operatingsystemrelease => 7.0" do - let(:facts) { {:operatingsystemrelease => 7.0 } } + let(:facts) { {:operatingsystemrelease => '7.0' } } it do should contain_class('nfs::client::redhat::install') should contain_class('nfs::client::redhat::configure') @@ -19,7 +19,7 @@ end context "operatingsystemrelease => 6.4" do - let(:facts) { {:operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystemrelease => '6.4' } } it do should contain_class('nfs::client::redhat::install') should contain_class('nfs::client::redhat::configure') @@ -64,14 +64,14 @@ context ":nfs_v4 => true" do let(:params) {{ :nfs_v4 => true }} - let(:facts) {{ :operatingsystemrelease => 6.4 }} + let(:facts) {{ :operatingsystemrelease => '6.4' }} it do should contain_augeas('/etc/idmapd.conf') end end context "operatingsystemrelease => 5.3" do - let(:facts) { {:operatingsystemrelease => 5.3 } } + let(:facts) { {:operatingsystemrelease => '5.3' } } it do should contain_class('nfs::client::redhat') should contain_package('portmap') diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb index 2a75696..bd6edfc 100644 --- a/spec/classes/client_spec.rb +++ b/spec/classes/client_spec.rb @@ -10,31 +10,31 @@ it { should contain_class('nfs::client::debian') } end context "operatingsysten => scientific" do - let(:facts) { {:operatingsystem => 'scientific', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'scientific', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => SLC" do - let(:facts) { {:operatingsystem => 'SLC', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'SLC', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => centos v7" do - let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => 7.0 } } + let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => '7.0' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => centos v6" do - let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => centos v5" do - let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => 5.4 } } + let(:facts) { {:operatingsystem => 'centos', :operatingsystemrelease => '5.4' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => redhat v7" do - let(:facts) { {:operatingsystem => 'redhat', :operatingsystemrelease => 7.0 } } + let(:facts) { {:operatingsystem => 'redhat', :operatingsystemrelease => '7.0' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => redhat v6" do - let(:facts) { {:operatingsystem => 'redhat', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'redhat', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::client::redhat') } end context "operatingsysten => Amazon v3" do diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb new file mode 100644 index 0000000..5f601cd --- /dev/null +++ b/spec/classes/coverage_spec.rb @@ -0,0 +1,4 @@ +# +# activate coverage calculation for the whole project +# +at_exit { RSpec::Puppet::Coverage.report! } diff --git a/spec/classes/server_debian_spec.rb b/spec/classes/server_debian_spec.rb index 5a52fd5..5208b43 100644 --- a/spec/classes/server_debian_spec.rb +++ b/spec/classes/server_debian_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' -describe 'nfs::server::debian' do +describe 'nfs::server::debian', :type => :class do it do should contain_class('nfs::client::debian') + should contain_class('nfs::server::debian::service') should contain_package('nfs-kernel-server') should contain_service('nfs-kernel-server').with( 'ensure' => 'running' ) end @@ -13,5 +14,12 @@ end end + context "mountd params set" do + let(:params) {{ :mountd_port => '4711' }} + it do + should contain_shellvar('rpc-mount-options') #.with( 'ensure' => 'present' ) + end + + end end diff --git a/spec/classes/server_gentoo_spec.rb b/spec/classes/server_gentoo_spec.rb index 633de53..31ad0ed 100644 --- a/spec/classes/server_gentoo_spec.rb +++ b/spec/classes/server_gentoo_spec.rb @@ -3,6 +3,7 @@ it do should contain_class('nfs::client::gentoo') + should contain_class('nfs::server::gentoo::service') should contain_service('nfs').with( 'ensure' => 'running' ) end context ":nfs_v4 => true" do diff --git a/spec/classes/server_redhat_spec.rb b/spec/classes/server_redhat_spec.rb index 8175e3e..cb5ca94 100644 --- a/spec/classes/server_redhat_spec.rb +++ b/spec/classes/server_redhat_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'nfs::server::redhat' do context "operatingsystemrelease => 6.4" do - let(:facts) { {:operatingsystemrelease => 6.4} } + let(:facts) { {:operatingsystemrelease => '6.4'} } it do should contain_class('nfs::client::redhat') should contain_service('nfs').with( 'ensure' => 'running' ) @@ -9,17 +9,27 @@ end context "operatingsystemrelease => 7.1" do - let(:facts) { {:operatingsystemrelease => 7.1} } + let(:facts) { {:operatingsystemrelease => '7.1'} } it do should contain_class('nfs::client::redhat') + should contain_class('nfs::server::redhat::service') should contain_service('nfs-server').with( 'ensure' => 'running' ) end - + context ":nfs_v4 => true" do let(:params) {{ :nfs_v4 => true , :nfs_v4_idmap_domain => 'teststring' }} it do should contain_augeas('/etc/idmapd.conf').with_changes(/set Domain teststring/) end end + + context "setting mountd port" do + let(:params) {{ :mountd_port => 4711 }} + it do + expect { + should contain_class('nfs::server::redhat') + }.to raise_error(Puppet::Error, /Setting mountd port currently not supported on RedHat/) + end + end end end diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 02dbf0f..897f8a4 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -17,24 +17,36 @@ let(:facts) { {:operatingsystem => 'ubuntu', :concat_basedir => '/tmp', } } it { should contain_class('nfs::server::debian') } end + + context "operatingsysten => ubuntu with params for mountd" do + let(:facts) { {:operatingsystem => 'ubuntu', :concat_basedir => '/tmp', } } + let(:params) {{ :mountd_port => '4711', :mountd_threads => '99' }} + + it do + should contain_class('nfs::server::debian').with( 'mountd_port' => '4711', 'mountd_threads' => '99' ) + end + end + context "operatingsysten => debian" do let(:facts) { {:operatingsystem => 'debian', :concat_basedir => '/tmp',} } it { should contain_class('nfs::server::debian') } end + context "operatingsysten => scientific" do - let(:facts) { {:operatingsystem => 'scientific', :concat_basedir => '/tmp', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'scientific', :concat_basedir => '/tmp', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::server::redhat') } end context "operatingsysten => SLC" do - let(:facts) { {:operatingsystem => 'SLC', :concat_basedir => '/tmp', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'SLC', :concat_basedir => '/tmp', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::server::redhat') } end + context "operatingsysten => centos v6" do - let(:facts) { {:operatingsystem => 'centos', :concat_basedir => '/tmp', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'centos', :concat_basedir => '/tmp', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::server::redhat') } end context "operatingsysten => redhat v6" do - let(:facts) { {:operatingsystem => 'redhat', :concat_basedir => '/tmp', :operatingsystemrelease => 6.4 } } + let(:facts) { {:operatingsystem => 'redhat', :concat_basedir => '/tmp', :operatingsystemrelease => '6.4' } } it { should contain_class('nfs::server::redhat') } end context "operatingsysten => Amazon v3" do diff --git a/spec/defines/client_spec.rb b/spec/defines/client_spec.rb index b9328a7..71be8d9 100644 --- a/spec/defines/client_spec.rb +++ b/spec/defines/client_spec.rb @@ -23,7 +23,7 @@ it do should compile should contain_class('nfs::client') - should contain_mount('shared nfs.int.net:/srv/share by test.example.com /srv/test') +# should contain_mount('shared nfs.int.net:/srv/share by test.example.com /srv/test') #should contain_mount('/srv/test') end end