From 11933653a3028d223286d1087d78adb8110a3ce8 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 13 Dec 2013 15:42:32 +0100 Subject: [PATCH 1/9] fix: changed clients type from string to array --- manifests/server/export.pp | 2 +- manifests/server/export/configure.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/server/export.pp b/manifests/server/export.pp index 7fe1bb0..1fb2aec 100644 --- a/manifests/server/export.pp +++ b/manifests/server/export.pp @@ -1,7 +1,7 @@ define nfs::server::export ( $v3_export_name = $name, $v4_export_name = regsubst($name, '.*/(.*)', '\1' ), - $clients = 'localhost(ro)', + $clients = ['localhost(ro)'], $bind = 'rbind', # globals for this share # propogated to storeconfigs diff --git a/manifests/server/export/configure.pp b/manifests/server/export/configure.pp index 220a534..c8d1ff2 100644 --- a/manifests/server/export/configure.pp +++ b/manifests/server/export/configure.pp @@ -4,7 +4,7 @@ ) { if $ensure != 'absent' { - $line = "${name} ${clients}\n" + $line = sprintf("%s %s\n", $name, join($clients, " ")) concat::fragment{ "${name}": From f969e5856fc996f4e415ff44334c16c3c4ad3359 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Mon, 16 Dec 2013 09:36:06 +0100 Subject: [PATCH 2/9] adjusted spec for exports (clients passed as array) --- spec/defines/server_export_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/defines/server_export_spec.rb b/spec/defines/server_export_spec.rb index 236ef81..709620c 100644 --- a/spec/defines/server_export_spec.rb +++ b/spec/defines/server_export_spec.rb @@ -4,7 +4,16 @@ describe 'nfs::server::export' do let(:facts) {{ :concat_basedir => '/dne' }} let(:title) { '/srv/test' } - #let(:params) {{ :server => 'nfs.int.net', :share => '/srv/share' } } + let(:params) {{ + #:server => 'nfs.int.net', + #:share => '/srv/share' + :clients => [ + 'localhost(ro)', + '$network}/$netmask(rw,async,all_squash,anonuid=99,anongid=99)', + 'nfsclient(ro)', + ] + }} + let(:facts){{:concat_basedir => '/var/lib/puppet/concat',}} it do should contain_nfs__server__export__configure('/srv/test') end From 58e10879809e8bd5ca2f1dd2aa193235993d0d4d Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 7 Feb 2014 16:46:27 +0100 Subject: [PATCH 3/9] Added ordering needed by nfs::client::mount --- manifests/client.pp | 4 ++++ manifests/client/mount.pp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/client.pp b/manifests/client.pp index fe16f19..37a3bf5 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -49,4 +49,8 @@ nfs_v4_idmap_domain => $nfs_v4_idmap_domain, } + Class["::nfs::client::${osfamily}::install"] -> + Class["::nfs::client::${osfamily}::configure"] -> + Class["::nfs::client::${osfamily}"] -> + Class['::nfs::client'] } diff --git a/manifests/client/mount.pp b/manifests/client/mount.pp index 0588bc6..74eb91a 100644 --- a/manifests/client/mount.pp +++ b/manifests/client/mount.pp @@ -32,7 +32,7 @@ ) { include nfs::client - + Class["nfs::client"] -> Nfs::Client::Mount["$title"] if $nfs::client::nfs_v4 == true { From dd87ac9693763d1a1007616cd8c7f5b671a58bd5 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Wed, 19 Mar 2014 09:17:05 +0100 Subject: [PATCH 4/9] mkdir now only ensures the directory is in the catalog, the were conflicts, when the directory was already created by another manifests --- manifests/mkdir.pp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/manifests/mkdir.pp b/manifests/mkdir.pp index 9192103..82274f2 100644 --- a/manifests/mkdir.pp +++ b/manifests/mkdir.pp @@ -1,16 +1,16 @@ # Nasty ass hax to allow several levels of directories +# Ensures the directory exists in the catalag define nfs::mkdir() { + if ! defined (File[$name]) { + exec { "mkdir_recurse_${name}" : + path => [ '/bin', '/usr/bin' ], + command => "mkdir -p ${name}", + unless => "test -d ${name}", + } - exec { "mkdir_recurse_${name}": - path => [ '/bin', '/usr/bin' ], - command => "mkdir -p ${name}", - unless => "test -d ${name}", - } - - file { - "${name}": - ensure => directory, - require => Exec["mkdir_recurse_${name}"] - } - -} + file { $name : + ensure => directory, + require => Exec["mkdir_recurse_${name}"] + } + } +} \ No newline at end of file From c66a51ca9c4ff6e88e9a7e6a21e423d89dfa8f09 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Wed, 16 Apr 2014 12:58:32 +0200 Subject: [PATCH 5/9] upd: nfs::client now includes nfs::client:${osfamily}, needed to install both server and client on the same node --- manifests/client.pp | 5 +---- manifests/client/debian.pp | 5 ++--- manifests/client/redhat.pp | 10 ++++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/manifests/client.pp b/manifests/client.pp index 37a3bf5..94e536a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -44,10 +44,7 @@ $nfs_v4_idmap_domain = $nfs::params::nfs_v4_idmap_domain ) inherits nfs::params { - class{ "nfs::client::${osfamily}": - nfs_v4 => $nfs_v4, - nfs_v4_idmap_domain => $nfs_v4_idmap_domain, - } + include "::nfs::client::${osfamily}" Class["::nfs::client::${osfamily}::install"] -> Class["::nfs::client::${osfamily}::configure"] -> diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index 03c6203..816fdaa 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -1,10 +1,9 @@ class nfs::client::debian ( - $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4 = $::nfs::client::nfs_v4, + $nfs_v4_idmap_domain = $::nfs::client::nfs_v4_idmap_domain, ) { include nfs::client::debian::install, nfs::client::debian::configure, nfs::client::debian::service - } diff --git a/manifests/client/redhat.pp b/manifests/client/redhat.pp index 257e780..34544af 100644 --- a/manifests/client/redhat.pp +++ b/manifests/client/redhat.pp @@ -2,13 +2,11 @@ # refactored a bit class nfs::client::redhat ( - $nfs_v4 = false, - $nfs_v4_idmap_domain = undef + $nfs_v4 = $::nfs::client::nfs_v4, + $nfs_v4_idmap_domain = $::nfs::client::nfs_v4_idmap_domain, ) inherits nfs::client::redhat::params { - include nfs::client::redhat::install, - nfs::client::redhat::configure, + include nfs::client::redhat::install, + nfs::client::redhat::configure, nfs::client::redhat::service - - } From 4437f61c912e2d589b8f50d8dfd6aba5ac13556c Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Thu, 15 May 2014 07:44:41 +0200 Subject: [PATCH 6/9] fix: FS resources should be managed outside of the module, added some 'ifs' to support that --- manifests/server/nfs_v4/configure.pp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/manifests/server/nfs_v4/configure.pp b/manifests/server/nfs_v4/configure.pp index 67e6393..15cb68a 100644 --- a/manifests/server/nfs_v4/configure.pp +++ b/manifests/server/nfs_v4/configure.pp @@ -6,9 +6,17 @@ content => "${nfs::server::nfs_v4_export_root} ${nfs::server::nfs_v4_export_root_clients}\n", order => 02 } - file { - "${nfs::server::nfs_v4_export_root}": - ensure => directory, + + + if defined (File[$nfs::server::nfs_v4_export_root]) and + ! defined_with_params(File[$nfs::server::nfs_v4_export_root], {'ensure' => 'directory' }) { + fail("Conflicting resource File[${nfs::server::nfs_v4_export_root}] needed in ${module_name}") + } + + if ! defined (File[$nfs::server::nfs_v4_export_root]) { + file { $nfs::server::nfs_v4_export_root: + ensure => directory, + } } @@nfs::client::mount::nfs_v4::root {"shared server root by ${::clientcert}": @@ -19,6 +27,6 @@ options => $nfs::server::nfs_v4_root_export_options, bindmount => $nfs::server::nfs_v4_root_export_bindmount, nfstag => $nfs::server::nfs_v4_root_export_tag, - server => "${::clientcert}", + server => "{::clientcert}", } } From 99786a0b3179c717a707f26d2bf2a5595e2d1f87 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 16 May 2014 11:58:37 +0200 Subject: [PATCH 7/9] fix: client_spec.rb --- spec/classes/client_spec.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb index 3dea98b..dd70900 100644 --- a/spec/classes/client_spec.rb +++ b/spec/classes/client_spec.rb @@ -3,30 +3,31 @@ describe 'nfs::client' do context "operatingsysten => ubuntu" do let(:facts) { {:operatingsystem => 'ubuntu', } } - it { should contain_class('nfs::client::debian') } + it { should include_class('nfs::client::debian') } end context "operatingsysten => debian" do let(:facts) { {:operatingsystem => 'debian', } } - it { should contain_class('nfs::client::debian') } + it { should include_class('nfs::client::debian') } end context "operatingsysten => scientific" do let(:facts) { {:operatingsystem => 'scientific', :osmajor => 6 } } - it { should contain_class('nfs::client::redhat') } + it { should include_class('nfs::client::redhat') } end context "operatingsysten => centos v6" do let(:facts) { {:operatingsystem => 'centos', :osmajor => 6 } } - it { should contain_class('nfs::client::redhat') } + it { should include_class('nfs::client::redhat') } end context "operatingsysten => redhat v6" do let(:facts) { {:operatingsystem => 'redhat', :osmajor => 6 } } - it { should contain_class('nfs::client::redhat') } + it { should include_class('nfs::client::redhat') } end context "operatingsystem => darwin" do let(:facts) { {:operatingsystem => 'darwin', } } - it do + it { expect { - should contain_class('nfs::server::darwin') - }.to raise_error(Puppet::Error, /NFS client is not supported on Darwin/) - end + should include_class('nfs::client::darwin' ) + should compile + }.to raise_error(Puppet::Error, /NFS client is not supported on Darwin/) + } end end From b62b4673c4abdd7dfdfda2ccc6f39889eb9140ab Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 16 May 2014 11:56:05 +0200 Subject: [PATCH 8/9] add: parameter whether to to manage or not the nfs service (needed for HA) --- manifests/client/debian.pp | 11 +++++++--- manifests/client/redhat.pp | 11 +++++++--- manifests/server.pp | 4 +++- manifests/server/darwin.pp | 5 +++-- manifests/server/debian.pp | 30 +++++++++++++++------------- manifests/server/nfs_v4/configure.pp | 2 +- manifests/server/redhat.pp | 14 ++++++++----- 7 files changed, 48 insertions(+), 29 deletions(-) diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index 816fdaa..84e616f 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -1,9 +1,14 @@ class nfs::client::debian ( $nfs_v4 = $::nfs::client::nfs_v4, $nfs_v4_idmap_domain = $::nfs::client::nfs_v4_idmap_domain, + $manage_service = true, ) { - include nfs::client::debian::install, - nfs::client::debian::configure, - nfs::client::debian::service + include nfs::client::debian::install + include nfs::client::debian::configure + + $do_manage_service = str2bool($manage_service) + if $do_manage_service { + include nfs::client::debian::service + } } diff --git a/manifests/client/redhat.pp b/manifests/client/redhat.pp index 34544af..de53a8e 100644 --- a/manifests/client/redhat.pp +++ b/manifests/client/redhat.pp @@ -4,9 +4,14 @@ class nfs::client::redhat ( $nfs_v4 = $::nfs::client::nfs_v4, $nfs_v4_idmap_domain = $::nfs::client::nfs_v4_idmap_domain, + $manage_service = true, ) 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 + + $do_manage_service = str2bool($manage_service) + if $do_manage_service { + include nfs::client::redhat::service + } } diff --git a/manifests/server.pp b/manifests/server.pp index 6c0e962..9c79b94 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -49,7 +49,9 @@ $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, + # + $nfs_manage_service = true, ) inherits nfs::params { class{ "nfs::server::${osfamily}": diff --git a/manifests/server/darwin.pp b/manifests/server/darwin.pp index f68173f..5f126c9 100644 --- a/manifests/server/darwin.pp +++ b/manifests/server/darwin.pp @@ -1,6 +1,7 @@ class nfs::server::darwin( $nfs_v4 = false, - $nfs_v4_idmap_domain = undef -) { + $nfs_v4_idmap_domain = undef, + $nfs_manage_service = $::nfs::server::nfs_manage_service, +) inherits nfs::server { fail("NFS server is not supported on Darwin") } diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index 1d6d3f1..7195658 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -1,8 +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, + $manage_service = $::nfs::server::nfs_manage_service, +) inherits nfs::server { class{ 'nfs::client::debian': nfs_v4 => $nfs_v4, @@ -13,20 +14,21 @@ ensure => 'installed', } - if $nfs_v4 == true { - service { - 'nfs-kernel-server': + $do_manage_service = str2bool($manage_service) + if $do_manage_service { + if $nfs_v4 == true { + service {'nfs-kernel-server': ensure => running, subscribe => [ Concat['/etc/exports'], - Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'] - ], - } - } else { - service { - 'nfs-kernel-server': - ensure => running, - subscribe => Concat['/etc/exports'], + Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'], + ], + } + } else { + service {'nfs-kernel-server': + ensure => running, + subscribe => Concat['/etc/exports'], + } } } } diff --git a/manifests/server/nfs_v4/configure.pp b/manifests/server/nfs_v4/configure.pp index 15cb68a..ca982e2 100644 --- a/manifests/server/nfs_v4/configure.pp +++ b/manifests/server/nfs_v4/configure.pp @@ -27,6 +27,6 @@ options => $nfs::server::nfs_v4_root_export_options, bindmount => $nfs::server::nfs_v4_root_export_bindmount, nfstag => $nfs::server::nfs_v4_root_export_tag, - server => "{::clientcert}", + server => "${::clientcert}", } } diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index 1282fbe..d75f0dc 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -1,14 +1,18 @@ class nfs::server::redhat( - $nfs_v4 = false, - $nfs_v4_idmap_domain = undef -) { + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef, + $manage_service = $::nfs::server::nfs_manage_service, +) inherits nfs::server { class{ 'nfs::client::redhat': nfs_v4 => $nfs_v4, nfs_v4_idmap_domain => $nfs_v4_idmap_domain, } - include nfs::server::redhat::install, nfs::server::redhat::service - + include nfs::server::redhat::install + $do_manage_service = str2bool($manage_service) + if $do_manage_service { + include nfs::server::redhat::service + } } From b4139e4613ba2f3381068575ebe32cea65bb3c74 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Wed, 28 May 2014 09:53:02 +0200 Subject: [PATCH 9/9] upd: travis configuration - puppet versions --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e7bfa2..08208d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ before_install: script: "rake spec" env: - PUPPET_VERSION=2.7.20 - - PUPPET_VERSION=3.0.2 - PUPPET_VERSION=3.1.0 - PUPPET_VERSION=3.4.3 + - PUPPET_VERSION=3.5.1 + - PUPPET_VERSION=3.6.1