From b4ddea6018c327ed3319f49a40959b78d5a6935b Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Tue, 29 Sep 2015 21:07:38 +0100 Subject: [PATCH 01/18] Add basic hiera support --- README.md | 13 +++++++++++++ manifests/server.pp | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d53fa88..0ff869e 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,19 @@ Export root, where we bind mount shares, default /export Domain setting for idmapd, must be the same across server and clients. Default is to use $domain fact. +#####`hiera_exports` (optional) + +If set, the hiera variable nfs::server::exports will be used to +construct nfs::server::export resources + +```hiera +nfs::server::hiera_exports: true +nfs::server::exports: + /mnt/something: + ensure: mounted + clients: '*(fsid=0,ro,insecure,async,all_squash,no_subtree_check,mountpoint=/mnt/something)' +``` + #####Examples ```puppet diff --git a/manifests/server.pp b/manifests/server.pp index 0e5712c..55a36eb 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -43,7 +43,9 @@ $nfs_v4_root_export_tag = undef, # $mountd_port = undef, - $mountd_threads = 1 + $mountd_threads = 1, + # + $hiera_exports = false ) inherits nfs::params { class { "nfs::server::${::nfs::params::osfamily}": @@ -55,4 +57,9 @@ include nfs::server::configure + if $hiera_exports { + $exports = hiera_hash('nfs::server::exports') + create_resources(nfs::server::export, $exports) + } + } From cf2d4f5df26c091c000f5562d33bf12a413c0667 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 30 Sep 2015 13:49:39 +0200 Subject: [PATCH 02/18] Remove unneeded call to hiera Explicit hiera call is not needed and should not be made inside modules. This pull request still allows the behaviour described in the README file. --- README.md | 8 ++++---- manifests/server.pp | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0ff869e..a62ed3e 100644 --- a/README.md +++ b/README.md @@ -347,13 +347,13 @@ Export root, where we bind mount shares, default /export Domain setting for idmapd, must be the same across server and clients. Default is to use $domain fact. -#####`hiera_exports` (optional) +#####`exports` (optional) -If set, the hiera variable nfs::server::exports will be used to -construct nfs::server::export resources +If set, this attribute will be used to +construct nfs::server::export resources. You can use you ENC or hiera to +provide the hash of nfs::server::export resources definitions: ```hiera -nfs::server::hiera_exports: true nfs::server::exports: /mnt/something: ensure: mounted diff --git a/manifests/server.pp b/manifests/server.pp index 55a36eb..4510a30 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -45,7 +45,7 @@ $mountd_port = undef, $mountd_threads = 1, # - $hiera_exports = false + $exports = undef, ) inherits nfs::params { class { "nfs::server::${::nfs::params::osfamily}": @@ -57,8 +57,7 @@ include nfs::server::configure - if $hiera_exports { - $exports = hiera_hash('nfs::server::exports') + if $exports { create_resources(nfs::server::export, $exports) } From 70ea022dc93300cd2d49c169a2648f5e5c886041 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 30 Sep 2015 13:22:49 +0200 Subject: [PATCH 03/18] (server) Add the ability to not manage the services MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The service_manage parameter name comes from puppetlabs modules (mysql, apacheā€¦) --- README.md | 5 ++++ manifests/client/debian/install.pp | 3 -- manifests/server.pp | 13 +++++++-- manifests/server/darwin.pp | 3 +- manifests/server/debian.pp | 8 ++++-- manifests/server/debian/service.pp | 38 ++++++++++++++----------- manifests/server/gentoo.pp | 3 +- manifests/server/gentoo/service.pp | 42 +++++++++++++++------------- manifests/server/redhat.pp | 10 +++++-- manifests/server/redhat/service.pp | 45 ++++++++++++++++-------------- spec/classes/server_redhat_spec.rb | 2 +- 11 files changed, 100 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index a62ed3e..39604b9 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,11 @@ Set up NFS server and exports. NFSv3 and NFSv4 supported. **Parameters within `nfs::server`:** +#####`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) NFSv4 support. Will set up automatic bind mounts to export root. diff --git a/manifests/client/debian/install.pp b/manifests/client/debian/install.pp index 3ac6d78..775db36 100644 --- a/manifests/client/debian/install.pp +++ b/manifests/client/debian/install.pp @@ -4,9 +4,6 @@ ensure => installed, } - Package['rpcbind'] -> Service['rpcbind'] - - package { ['nfs-common', 'nfs4-acl-tools']: ensure => installed, } diff --git a/manifests/server.pp b/manifests/server.pp index 4510a30..6d8253b 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -13,9 +13,13 @@ # Export root, where we bind mount shares, default /export # # [nfs_v4_idmap_domain] -# Domain setting for idmapd, must be the same across server -# and clients. -# Default is to use $domain fact. +# Domain setting for idmapd, must be the same across server +# and clients. +# Default is to use $domain fact. +# +# [service_manage] +# Should this class manage the services behind nfs? Set this to false +# if you are managing the service in another way (e.g. pacemaker). # # === Examples # @@ -34,6 +38,8 @@ $nfs_v4_export_root_clients = $nfs::params::nfs_v4_export_root_clients, $nfs_v4_idmap_domain = $nfs::params::nfs_v4_idmap_domain, # + $service_manage = true, + # $nfs_v4_root_export_ensure = 'mounted', $nfs_v4_root_export_mount = undef, $nfs_v4_root_export_remounts = false, @@ -53,6 +59,7 @@ nfs_v4_idmap_domain => $nfs_v4_idmap_domain, mountd_port => $mountd_port, mountd_threads => $mountd_threads, + service_manage => $service_manage, } include nfs::server::configure diff --git a/manifests/server/darwin.pp b/manifests/server/darwin.pp index f6181ae..73fedc5 100644 --- a/manifests/server/darwin.pp +++ b/manifests/server/darwin.pp @@ -2,7 +2,8 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1 + $mountd_threads = 1, + $service_manage = true, ) { fail('NFS server is not supported on Darwin') } diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index bd5d32f..22671a0 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -3,7 +3,8 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1 + $mountd_threads = 1, + $service_manage = true, ) { if !defined(Class['nfs::client::debian']) { @@ -19,7 +20,10 @@ target => '/etc/default/nfs-kernel-server', variable => 'RPCMOUNTDOPTS', value => "--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}", - notify => Service['nfs-kernel-server'], + } + + if $service_manage { + Shellvar['rpc-mount-options'] ~> Service['nfs-kernel-server'] } } diff --git a/manifests/server/debian/service.pp b/manifests/server/debian/service.pp index 58fd101..b895181 100644 --- a/manifests/server/debian/service.pp +++ b/manifests/server/debian/service.pp @@ -1,22 +1,26 @@ class nfs::server::debian::service { - if $nfs::server::debian::nfs_v4 == true { - service {'nfs-kernel-server': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['nfs-kernel-server'], - subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf','/etc/default/nfs-common'] ], - } - } else { - service {'nfs-kernel-server': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['nfs-kernel-server'], - subscribe => Concat['/etc/exports'], + if $nfs::server::debian::service_manage { + if $nfs::server::debian::nfs_v4 == true { + service {'nfs-kernel-server': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-kernel-server'], + subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf','/etc/default/nfs-common'] ], + } + } else { + service {'nfs-kernel-server': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-kernel-server'], + subscribe => Concat['/etc/exports'], + } } + + Package['rpcbind'] -> Service['rpcbind'] } } diff --git a/manifests/server/gentoo.pp b/manifests/server/gentoo.pp index a74a501..2bc46b1 100644 --- a/manifests/server/gentoo.pp +++ b/manifests/server/gentoo.pp @@ -3,7 +3,8 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1 + $mountd_threads = 1, + $service_manage = true, ) { if !defined(Class['nfs::client::gentoo']) { diff --git a/manifests/server/gentoo/service.pp b/manifests/server/gentoo/service.pp index 129c348..5119cb9 100644 --- a/manifests/server/gentoo/service.pp +++ b/manifests/server/gentoo/service.pp @@ -1,25 +1,27 @@ class nfs::server::gentoo::service { - if $::nfs::client::gentoo::nfs_v4 == true { - service { 'nfs': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['net-fs/nfs-utils'], - subscribe => [ - Concat['/etc/exports'], - Augeas['/etc/idmapd.conf', '/etc/conf.d/nfs'] - ], - } - } else { - service { 'nfs': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['net-fs/nfs-utils'], - subscribe => Concat['/etc/exports'], + if $nfs::server::gentoo::service_manage { + if $::nfs::client::gentoo::nfs_v4 == true { + service { 'nfs': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['net-fs/nfs-utils'], + subscribe => [ + Concat['/etc/exports'], + Augeas['/etc/idmapd.conf', '/etc/conf.d/nfs'] + ], + } + } else { + service { 'nfs': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['net-fs/nfs-utils'], + subscribe => Concat['/etc/exports'], + } } } } diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index cd04ee8..5baae87 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -2,9 +2,10 @@ $nfs_v4 = false, $nfs_v4_idmap_domain = undef, $mountd_port = undef, - $mountd_threads = 1 + $mountd_threads = 1, + $service_manage = true, ) { - if ($::operatingsystemmajrelease == defined) and ($::operatingsystemmajrelease =~ /^7/) { + if $::operatingsystemmajrelease and $::operatingsystemmajrelease =~ /^7/ { $service_name = 'nfs-server' } else { $service_name = 'nfs' @@ -23,7 +24,10 @@ target => '/etc/sysconfig/nfs', variable => 'MOUNTD_PORT', value => $mountd_port, - notify => Service[$service_name], + } + + if $service_manage { + Shellvar['rpc-mount-options'] ~> Service[$service_name] } } diff --git a/manifests/server/redhat/service.pp b/manifests/server/redhat/service.pp index 4ec08da..7cc52ad 100644 --- a/manifests/server/redhat/service.pp +++ b/manifests/server/redhat/service.pp @@ -1,27 +1,30 @@ class nfs::server::redhat::service { - if $::nfs::client::redhat::params::osmajor >= 7 { - $service_name = 'nfs-server' - } else { - $service_name = 'nfs' - } - if $nfs::server::redhat::nfs_v4 == true { - service {$service_name: - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['nfs-utils'], - subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf'] ], + if $nfs::server::redhat::service_manage { + if $::operatingsystemmajrelease and $::operatingsystemmajrelease =~ /^7/ { + $service_name = 'nfs-server' + } else { + $service_name = 'nfs' } - } else { - service {$service_name: - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package['nfs-utils'], - subscribe => Concat['/etc/exports'], + + if $nfs::server::redhat::nfs_v4 == true { + service {$service_name: + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-utils'], + subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf'] ], + } + } else { + service {$service_name: + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-utils'], + subscribe => Concat['/etc/exports'], + } } } } diff --git a/spec/classes/server_redhat_spec.rb b/spec/classes/server_redhat_spec.rb index 914bcab..81a0da6 100644 --- a/spec/classes/server_redhat_spec.rb +++ b/spec/classes/server_redhat_spec.rb @@ -7,7 +7,7 @@ should contain_service('nfs').with( 'ensure' => 'running' ) end end - + context "operatingsystemrelease => 7.1" do let(:facts) { {:operatingsystemrelease => '7.1', :operatingsystemmajrelease => '7'} } it do From 11172384276bedd60e845ae993c7c5aa2edf9255 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 30 Sep 2015 14:28:20 +0200 Subject: [PATCH 04/18] Speed up puppet parser validate tests --- Rakefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 125cbfc..c35cebb 100644 --- a/Rakefile +++ b/Rakefile @@ -13,9 +13,7 @@ PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] desc "Validate manifests, templates, and ruby files in lib." task :validate do - Dir['manifests/**/*.pp'].each do |manifest| - sh "puppet parser validate --noop #{manifest}" - end + sh "puppet parser validate --noop #{Dir['manifests/**/*.pp'].join(" ")}" Dir['lib/**/*.rb'].each do |lib_file| sh "ruby -c #{lib_file}" end From 4306690dd350ca6cd1e5c4b25447795a829ac658 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 30 Sep 2015 13:12:06 +0200 Subject: [PATCH 05/18] (lint) Align = and remove extra line --- manifests/client/redhat/service.pp | 1 - manifests/server.pp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manifests/client/redhat/service.pp b/manifests/client/redhat/service.pp index 8d473a2..0781ff4 100644 --- a/manifests/client/redhat/service.pp +++ b/manifests/client/redhat/service.pp @@ -37,7 +37,6 @@ } } - 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 6d8253b..56633c4 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -48,8 +48,8 @@ $nfs_v4_root_export_bindmount = undef, $nfs_v4_root_export_tag = undef, # - $mountd_port = undef, - $mountd_threads = 1, + $mountd_port = undef, + $mountd_threads = 1, # $exports = undef, ) inherits nfs::params { From 47c41773ba915f3e4f254ffc4290461fc90b854c Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Mon, 12 Oct 2015 15:20:09 +0200 Subject: [PATCH 06/18] update test commands --- DEVELOP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOP.md b/DEVELOP.md index 99d9fca..f4aec9f 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -22,7 +22,7 @@ Tests are written with [rspec-puppet](http://rspec-puppet.com/). CI is covered b To run all tests: - rake spec + bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation' Branching --------- From 426ad8f82c7189a951e966589d28c4917d762e0c Mon Sep 17 00:00:00 2001 From: "daniel.werdermann" Date: Mon, 12 Oct 2015 15:21:25 +0200 Subject: [PATCH 07/18] clone debian config to ubuntu --- manifests/client/ubuntu.pp | 10 +++++++++ manifests/client/ubuntu/configure.pp | 19 +++++++++++++++++ manifests/client/ubuntu/install.pp | 11 ++++++++++ manifests/client/ubuntu/service.pp | 20 ++++++++++++++++++ manifests/params.pp | 12 +++++------ manifests/server/ubuntu.pp | 31 ++++++++++++++++++++++++++++ manifests/server/ubuntu/install.pp | 7 +++++++ manifests/server/ubuntu/service.pp | 26 +++++++++++++++++++++++ spec/classes/client_spec.rb | 2 +- spec/classes/client_ubuntu_spec.rb | 31 ++++++++++++++++++++++++++++ spec/classes/server_spec.rb | 4 ++-- spec/classes/server_ubuntu_spec.rb | 25 ++++++++++++++++++++++ 12 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 manifests/client/ubuntu.pp create mode 100644 manifests/client/ubuntu/configure.pp create mode 100644 manifests/client/ubuntu/install.pp create mode 100644 manifests/client/ubuntu/service.pp create mode 100644 manifests/server/ubuntu.pp create mode 100644 manifests/server/ubuntu/install.pp create mode 100644 manifests/server/ubuntu/service.pp create mode 100644 spec/classes/client_ubuntu_spec.rb create mode 100644 spec/classes/server_ubuntu_spec.rb diff --git a/manifests/client/ubuntu.pp b/manifests/client/ubuntu.pp new file mode 100644 index 0000000..f810021 --- /dev/null +++ b/manifests/client/ubuntu.pp @@ -0,0 +1,10 @@ +class nfs::client::ubuntu ( + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef +) { + + include nfs::client::ubuntu::install, + nfs::client::ubuntu::configure, + nfs::client::ubuntu::service + +} diff --git a/manifests/client/ubuntu/configure.pp b/manifests/client/ubuntu/configure.pp new file mode 100644 index 0000000..8017baa --- /dev/null +++ b/manifests/client/ubuntu/configure.pp @@ -0,0 +1,19 @@ +class nfs::client::ubuntu::configure { + Augeas{ + require => Class['nfs::client::ubuntu::install'] + } + + if $nfs::client::ubuntu::nfs_v4 { + augeas { + '/etc/default/nfs-common': + context => '/files/etc/default/nfs-common', + changes => [ 'set NEED_IDMAPD yes', ]; + '/etc/idmapd.conf': + context => '/files/etc/idmapd.conf/General', + lens => 'Puppet.lns', + incl => '/etc/idmapd.conf', + changes => ["set Domain ${nfs::client::ubuntu::nfs_v4_idmap_domain}"], + } + } + +} diff --git a/manifests/client/ubuntu/install.pp b/manifests/client/ubuntu/install.pp new file mode 100644 index 0000000..671db42 --- /dev/null +++ b/manifests/client/ubuntu/install.pp @@ -0,0 +1,11 @@ +class nfs::client::ubuntu::install { + + package { 'rpcbind': + ensure => installed, + } + + package { ['nfs-common', 'nfs4-acl-tools']: + ensure => installed, + } + +} diff --git a/manifests/client/ubuntu/service.pp b/manifests/client/ubuntu/service.pp new file mode 100644 index 0000000..323352c --- /dev/null +++ b/manifests/client/ubuntu/service.pp @@ -0,0 +1,20 @@ +class nfs::client::ubuntu::service { + Service { + require => Class['nfs::client::ubuntu::configure'] + } + + service { 'rpcbind': + ensure => running, + enable => true, + hasstatus => false, + } + + if $nfs::client::ubuntu::nfs_v4 { + service { 'idmapd': + ensure => running, + subscribe => Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'], + } + } else { + service { 'idmapd': ensure => stopped, } + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 9b1921c..3a23757 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,11 +9,11 @@ # Somehow the ::osfamily fact doesnt exist on some systems case $::operatingsystem { - 'centos', 'redhat', 'scientific', 'fedora', 'SLC', 'OracleLinux', 'Amazon' : { $osfamily = 'redhat' } - 'debian', 'Ubuntu' : { $osfamily = 'debian' } - 'windows' : { fail('fail!11') } - 'darwin' : { $osfamily = 'darwin' } - 'gentoo' : { $osfamily = 'gentoo' } - default : { fail("OS: ${::operatingsystem} not supported") } + 'CentOS', 'RedHat', 'scientific', 'Fedora', 'SLC', 'OracleLinux', 'Amazon' : { $osfamily = 'redhat' } + 'Debian' : { $osfamily = 'debian' } + 'Ubuntu' : { $osfamily = 'ubuntu' } + 'darwin' : { $osfamily = 'darwin' } + 'gentoo' : { $osfamily = 'gentoo' } + default : { fail("OS: ${::operatingsystem} not supported") } } } diff --git a/manifests/server/ubuntu.pp b/manifests/server/ubuntu.pp new file mode 100644 index 0000000..0f52df9 --- /dev/null +++ b/manifests/server/ubuntu.pp @@ -0,0 +1,31 @@ +# Debian specifix stuff +class nfs::server::ubuntu( + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef, + $mountd_port = undef, + $mountd_threads = 1, + $service_manage = true, +) { + + if !defined(Class['nfs::client::ubuntu']) { + class{ 'nfs::client::ubuntu': + nfs_v4 => $nfs_v4, + nfs_v4_idmap_domain => $nfs_v4_idmap_domain, + } + } + + 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}", + } + + if $service_manage { + Shellvar['rpc-mount-options'] ~> Service['nfs-kernel-server'] + } + } + + include nfs::server::ubuntu::install, nfs::server::ubuntu::service +} diff --git a/manifests/server/ubuntu/install.pp b/manifests/server/ubuntu/install.pp new file mode 100644 index 0000000..83a7629 --- /dev/null +++ b/manifests/server/ubuntu/install.pp @@ -0,0 +1,7 @@ +class nfs::server::ubuntu::install { + + package { 'nfs-kernel-server': + ensure => installed + } + +} diff --git a/manifests/server/ubuntu/service.pp b/manifests/server/ubuntu/service.pp new file mode 100644 index 0000000..1079aa4 --- /dev/null +++ b/manifests/server/ubuntu/service.pp @@ -0,0 +1,26 @@ +class nfs::server::ubuntu::service { + + if $nfs::server::ubuntu::service_manage { + if $nfs::server::ubuntu::nfs_v4 == true { + service {'nfs-kernel-server': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-kernel-server'], + subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf','/etc/default/nfs-common'] ], + } + } else { + service {'nfs-kernel-server': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package['nfs-kernel-server'], + subscribe => Concat['/etc/exports'], + } + } + + Package['rpcbind'] -> Service['rpcbind'] + } +} diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb index bd6edfc..37215c5 100644 --- a/spec/classes/client_spec.rb +++ b/spec/classes/client_spec.rb @@ -3,7 +3,7 @@ describe 'nfs::client' do context "operatingsysten => ubuntu" do let(:facts) { {:operatingsystem => 'ubuntu', } } - it { should contain_class('nfs::client::debian') } + it { should contain_class('nfs::client::ubuntu') } end context "operatingsysten => debian" do let(:facts) { {:operatingsystem => 'debian', } } diff --git a/spec/classes/client_ubuntu_spec.rb b/spec/classes/client_ubuntu_spec.rb new file mode 100644 index 0000000..0140614 --- /dev/null +++ b/spec/classes/client_ubuntu_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' +describe 'nfs::client::ubuntu' do + + it do + should contain_class('nfs::client::ubuntu::install') + should contain_class('nfs::client::ubuntu::configure') + should contain_class('nfs::client::ubuntu::service') + + should contain_service('rpcbind').with( + 'ensure' => 'running' + ) + + should contain_service('idmapd').with( + 'ensure' => 'stopped' + ) + should contain_package('nfs-common') + should contain_package('rpcbind') + + should contain_package('nfs4-acl-tools') + end + context ":nfs_v4 => true" do + let(:params) {{ :nfs_v4 => true }} + it do + should contain_augeas('/etc/idmapd.conf') + should contain_service('idmapd').with( + 'ensure' => 'running' + ) + end + end + +end diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 897f8a4..0a6717b 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -15,7 +15,7 @@ context "operatingsysten => ubuntu" do let(:facts) { {:operatingsystem => 'ubuntu', :concat_basedir => '/tmp', } } - it { should contain_class('nfs::server::debian') } + it { should contain_class('nfs::server::ubuntu') } end context "operatingsysten => ubuntu with params for mountd" do @@ -23,7 +23,7 @@ let(:params) {{ :mountd_port => '4711', :mountd_threads => '99' }} it do - should contain_class('nfs::server::debian').with( 'mountd_port' => '4711', 'mountd_threads' => '99' ) + should contain_class('nfs::server::ubuntu').with( 'mountd_port' => '4711', 'mountd_threads' => '99' ) end end diff --git a/spec/classes/server_ubuntu_spec.rb b/spec/classes/server_ubuntu_spec.rb new file mode 100644 index 0000000..731e0bd --- /dev/null +++ b/spec/classes/server_ubuntu_spec.rb @@ -0,0 +1,25 @@ + +require 'spec_helper' +describe 'nfs::server::ubuntu', :type => :class do + it do + should contain_class('nfs::client::ubuntu') + should contain_class('nfs::server::ubuntu::service') + should contain_package('nfs-kernel-server') + should contain_service('nfs-kernel-server').with( 'ensure' => 'running' ) + end + context ":nfs_v4 => true" do + let(:params) {{ :nfs_v4 => true }} + it do + should contain_service('idmapd').with( 'ensure' => 'running' ) + 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 + From f84c3429968508b15940d04c4eacff6eabd7d3b0 Mon Sep 17 00:00:00 2001 From: "daniel.werdermann" Date: Mon, 12 Oct 2015 16:05:32 +0200 Subject: [PATCH 08/18] set client class dependencies --- manifests/client/debian.pp | 10 ++++++--- manifests/client/debian/configure.pp | 3 --- manifests/client/debian/service.pp | 3 --- manifests/client/gentoo.pp | 11 +++++++--- manifests/client/redhat.pp | 13 ++++++----- manifests/client/redhat/configure.pp | 1 - manifests/client/redhat/service.pp | 4 ---- manifests/client/ubuntu.pp | 10 ++++++--- manifests/client/ubuntu/configure.pp | 3 --- manifests/client/ubuntu/service.pp | 3 --- metadata.json | 33 ++++++++++++++++++++++++++++ 11 files changed, 62 insertions(+), 32 deletions(-) diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index 03c6203..a3c9a58 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -3,8 +3,12 @@ $nfs_v4_idmap_domain = undef ) { - include nfs::client::debian::install, - nfs::client::debian::configure, - nfs::client::debian::service + include ::nfs::client::debian::install + include ::nfs::client::debian::configure + include ::nfs::client::debian::service + + Class['::nfs::client::debian::install']-> + Class['::nfs::client::debian::configure']-> + Class['::nfs::client::debian::service'] } diff --git a/manifests/client/debian/configure.pp b/manifests/client/debian/configure.pp index 0db2868..50c59e6 100644 --- a/manifests/client/debian/configure.pp +++ b/manifests/client/debian/configure.pp @@ -1,7 +1,4 @@ class nfs::client::debian::configure { - Augeas{ - require => Class['nfs::client::debian::install'] - } if $nfs::client::debian::nfs_v4 { augeas { diff --git a/manifests/client/debian/service.pp b/manifests/client/debian/service.pp index 0d0537f..8178306 100644 --- a/manifests/client/debian/service.pp +++ b/manifests/client/debian/service.pp @@ -1,7 +1,4 @@ class nfs::client::debian::service { - Service { - require => Class['nfs::client::debian::configure'] - } service { 'rpcbind': ensure => running, diff --git a/manifests/client/gentoo.pp b/manifests/client/gentoo.pp index 3d1a747..2b5c954 100644 --- a/manifests/client/gentoo.pp +++ b/manifests/client/gentoo.pp @@ -3,8 +3,13 @@ $nfs_v4_idmap_domain = undef ) { - include nfs::client::gentoo::install, - nfs::client::gentoo::configure, - nfs::client::gentoo::service + include ::nfs::client::gentoo::install + include ::nfs::client::gentoo::configure + include ::nfs::client::gentoo::service + + Class['::nfs::client::gentoo::install']-> + Class['::nfs::client::gentoo::configure']-> + Class['::nfs::client::gentoo::service'] + } diff --git a/manifests/client/redhat.pp b/manifests/client/redhat.pp index 22b3d52..09d20c1 100644 --- a/manifests/client/redhat.pp +++ b/manifests/client/redhat.pp @@ -1,13 +1,14 @@ -# Shamefully stolen from https://github.com/frimik/puppet-nfs -# refactored a bit - class nfs::client::redhat ( $nfs_v4 = false, $nfs_v4_idmap_domain = undef ) inherits nfs::client::redhat::params { - include nfs::client::redhat::install, - nfs::client::redhat::configure, - nfs::client::redhat::service + include ::nfs::client::redhat::install + include ::nfs::client::redhat::configure + include ::nfs::client::redhat::service + + Class['::nfs::client::redhat::install']-> + Class['::nfs::client::redhat::configure']-> + Class['::nfs::client::redhat::service'] } diff --git a/manifests/client/redhat/configure.pp b/manifests/client/redhat/configure.pp index 7b21dec..93a1f79 100644 --- a/manifests/client/redhat/configure.pp +++ b/manifests/client/redhat/configure.pp @@ -3,7 +3,6 @@ class nfs::client::redhat::configure { - if $nfs::client::redhat::nfs_v4 { augeas { '/etc/idmapd.conf': diff --git a/manifests/client/redhat/service.pp b/manifests/client/redhat/service.pp index 0781ff4..000230d 100644 --- a/manifests/client/redhat/service.pp +++ b/manifests/client/redhat/service.pp @@ -3,10 +3,6 @@ class nfs::client::redhat::service { - Service { - require => Class['nfs::client::redhat::configure'] - } - # lint:ignore:selector_inside_resource would not add much to readability service {'nfslock': diff --git a/manifests/client/ubuntu.pp b/manifests/client/ubuntu.pp index f810021..82afac9 100644 --- a/manifests/client/ubuntu.pp +++ b/manifests/client/ubuntu.pp @@ -3,8 +3,12 @@ $nfs_v4_idmap_domain = undef ) { - include nfs::client::ubuntu::install, - nfs::client::ubuntu::configure, - nfs::client::ubuntu::service + include ::nfs::client::ubuntu::install + include ::nfs::client::ubuntu::configure + include ::nfs::client::ubuntu::service + + Class['::nfs::client::ubuntu::install']-> + Class['::nfs::client::ubuntu::configure']-> + Class['::nfs::client::ubuntu::service'] } diff --git a/manifests/client/ubuntu/configure.pp b/manifests/client/ubuntu/configure.pp index 8017baa..e591d6c 100644 --- a/manifests/client/ubuntu/configure.pp +++ b/manifests/client/ubuntu/configure.pp @@ -1,7 +1,4 @@ class nfs::client::ubuntu::configure { - Augeas{ - require => Class['nfs::client::ubuntu::install'] - } if $nfs::client::ubuntu::nfs_v4 { augeas { diff --git a/manifests/client/ubuntu/service.pp b/manifests/client/ubuntu/service.pp index 323352c..e5fcc2f 100644 --- a/manifests/client/ubuntu/service.pp +++ b/manifests/client/ubuntu/service.pp @@ -1,7 +1,4 @@ class nfs::client::ubuntu::service { - Service { - require => Class['nfs::client::ubuntu::configure'] - } service { 'rpcbind': ensure => running, diff --git a/metadata.json b/metadata.json index 043cbeb..2646f82 100644 --- a/metadata.json +++ b/metadata.json @@ -2,18 +2,51 @@ "operatingsystem_support": [ { "operatingsystem": "RedHat" + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "CentOS" + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "Scientific" + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "Debian" + "operatingsystemrelease": [ + "6", + "7", + "8" + ] }, { "operatingsystem": "Ubuntu" + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] } ], "requirements": [ From b2f3524ecafb62d969b0492171658de400f7d925 Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 08:43:57 +0200 Subject: [PATCH 09/18] update Gemfile to work with rspec 3.3.0 --- Gemfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 189b7c5..4cfb5ef 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ -source 'https://rubygems.org' +source ENV['GEM_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 'puppet', puppetversion, :require => false gem 'puppetlabs_spec_helper', '>= 0.1.0' -gem 'puppet-lint', '>= 0.3.2' -gem 'facter', facterversion -gem 'rspec', '< 3.2.0' +gem 'puppet-lint', '>= 0.3.2', :require => false +gem 'facter', facterversion, :require => false +gem 'rspec', '<= 3.3.0', :require => false From f994dc17bbddfba132091644c0e262275e9f5e88 Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 08:50:05 +0200 Subject: [PATCH 10/18] gitignore eclipse .project and other stuff --- .gitignore | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 68ed3cb..5846875 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,51 @@ -spec/fixtures/modules/* -spec/fixtures/manifests/* -*swp +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Beaker/Vagrant +.vagrant/ + +# Puppet Files +pkg +spec/fixtures +.rspec_system +.vagrant/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalisation: +/.bundle/ +/lib/bundler/man/ -.DS_Store Gemfile.lock +.ruby-version +.ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# idea +./idea + +# geppetto/eclipse +.project + +# others +*swp +.DS_Store From fbd63880278f73da35b2b2aa720a849e548c524a Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 08:54:43 +0200 Subject: [PATCH 11/18] prepare release 1.7.0 --- CHANGELOG.md | 13 +++++++++++++ metadata.json | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f59f6..a3e8617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## 2015-10-16 - 1.7.0 (Feature/Bugfixe release) + +#### Features: + +- (cf2d4f5) #37 #41 add optinal parameter `exports` for class server +- (70ea022) #42 add the ability to manage the services. See `service_manage` +- (1117238) #43 speed up puppet parser validate tests + +#### Bugfixes: + +- (426ad8f) #27 #44 add special config for ubuntu to fix service name bug for idmapd +- (f84c342) #45 ensure order of client class dependencies + ## 2015-09-29 - 1.6.0 (Feature/Bugfixe release) #### Features: diff --git a/metadata.json b/metadata.json index 2646f82..019dd48 100644 --- a/metadata.json +++ b/metadata.json @@ -52,7 +52,7 @@ "requirements": [ { "name": "pe", - "version_requirement": "3.x" + "version_requirement": ">= 3.7.0" }, { "name": "puppet", @@ -60,7 +60,7 @@ } ], "name": "echocat-nfs", - "version": "1.6.0", + "version": "1.7.0", "source": "git clone https://github.com/echocat/puppet-nfs.git", "author": "echocat", "license": "Apache-2.0", @@ -68,7 +68,7 @@ "project_page": "https://github.com/echocat/puppet-nfs", "issues_url": "https://github.com/echocat/puppet-nfs/issues", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"}, + {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <2.0.0"}, {"name":"herculesteam/augeasproviders_shellvar","version_requirement":">= 2.1.0"} ] From 86c02aa3407908af637e5cbd8185cdcb63730349 Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 10:26:12 +0200 Subject: [PATCH 12/18] fix metadata syntax --- metadata.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/metadata.json b/metadata.json index 019dd48..c58367f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,7 +1,7 @@ { "operatingsystem_support": [ { - "operatingsystem": "RedHat" + "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", @@ -9,7 +9,7 @@ ] }, { - "operatingsystem": "CentOS" + "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", @@ -17,7 +17,7 @@ ] }, { - "operatingsystem": "Scientific" + "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", @@ -25,7 +25,7 @@ ] }, { - "operatingsystem": "Debian" + "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7", @@ -33,7 +33,7 @@ ] }, { - "operatingsystem": "Ubuntu" + "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", @@ -68,7 +68,7 @@ "project_page": "https://github.com/echocat/puppet-nfs", "issues_url": "https://github.com/echocat/puppet-nfs/issues", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, + {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 5.0.0"}, {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <2.0.0"}, {"name":"herculesteam/augeasproviders_shellvar","version_requirement":">= 2.1.0"} ] From a4be91c0636861e6fcbb5ca13d4238ac179e533f Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 11:09:32 +0200 Subject: [PATCH 13/18] fix metadata dependencies --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index c58367f..9c8beaa 100644 --- a/metadata.json +++ b/metadata.json @@ -68,8 +68,8 @@ "project_page": "https://github.com/echocat/puppet-nfs", "issues_url": "https://github.com/echocat/puppet-nfs/issues", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 5.0.0"}, - {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <2.0.0"}, + {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, + {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 < 2.0.0"}, {"name":"herculesteam/augeasproviders_shellvar","version_requirement":">= 2.1.0"} ] } From 1955bf8a58aeedabb1457df12a2772055bb49057 Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 11:12:21 +0200 Subject: [PATCH 14/18] add some variable validation --- manifests/client.pp | 2 ++ manifests/server.pp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/client.pp b/manifests/client.pp index afc5c2f..7a8e3d0 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -34,6 +34,8 @@ $nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain ) inherits nfs::params { + validate_bool($nfs_v4) + # ensure dependencies for mount Class["::nfs::client::${::nfs::params::osfamily}::install"] -> diff --git a/manifests/server.pp b/manifests/server.pp index 56633c4..748a12a 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -33,7 +33,7 @@ # } class nfs::server ( - $nfs_v4 = $nfs::params::nfs_v4, + $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, $nfs_v4_idmap_domain = $nfs::params::nfs_v4_idmap_domain, @@ -54,6 +54,11 @@ $exports = undef, ) inherits nfs::params { + validate_bool($nfs_v4) + validate_bool($service_manage) + validate_bool($nfs_v4_root_export_remounts) + validate_bool($nfs_v4_root_export_atboot) + class { "nfs::server::${::nfs::params::osfamily}": nfs_v4 => $nfs_v4, nfs_v4_idmap_domain => $nfs_v4_idmap_domain, From 0b5098123d8312fdf7a5532d49ad69346cd58b91 Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 11:45:52 +0200 Subject: [PATCH 15/18] Update Gemfile --- Gemfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 4cfb5ef..ef4406b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source ENV['GEM_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, :require => false +gem 'puppet', puppetversion gem 'puppetlabs_spec_helper', '>= 0.1.0' -gem 'puppet-lint', '>= 0.3.2', :require => false -gem 'facter', facterversion, :require => false -gem 'rspec', '<= 3.3.0', :require => false +gem 'puppet-lint', '>= 0.3.2' +gem 'facter', facterversion +gem 'rspec', '<= 3.3.0' From caeaecbb084ba06375cb9237bddd47a4b881c20b Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 11:54:43 +0200 Subject: [PATCH 16/18] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ef4406b..d832a99 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +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'] From f368f7adf83570de644d8aae97ea7b7bf2b3727f Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 14:10:20 +0200 Subject: [PATCH 17/18] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d832a99..033201f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,4 @@ gem 'puppet', puppetversion gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppet-lint', '>= 0.3.2' gem 'facter', facterversion -gem 'rspec', '<= 3.3.0' +gem 'rspec', '<= 3.2.0' From 0a47eddd3acfc51eea91f7501166255b7db2b91a Mon Sep 17 00:00:00 2001 From: Daniel Werdermann Date: Fri, 16 Oct 2015 14:35:55 +0200 Subject: [PATCH 18/18] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 033201f..189b7c5 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,4 @@ gem 'puppet', puppetversion gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppet-lint', '>= 0.3.2' gem 'facter', facterversion -gem 'rspec', '<= 3.2.0' +gem 'rspec', '< 3.2.0'