From faa346f39e591e1dff891ada2bc364028f4e45b8 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 22 Sep 2015 13:34:35 +0000 Subject: [PATCH 1/3] Enable mountd_port parameter for Red Hat. --- manifests/server/redhat.pp | 14 ++++++++++++-- spec/classes/server_redhat_spec.rb | 8 +++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index dd26d4b..0a53e04 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -4,6 +4,11 @@ $mountd_port = undef, $mountd_threads = 1 ) { + if $::operatingsystemmajrelease =~ /^7/ { + $service_name = 'nfs-server' + } else { + $service_name = 'nfs' + } if !defined(Class['nfs::client::redhat']) { class{ 'nfs::client::redhat': @@ -13,10 +18,15 @@ } if ($mountd_port != undef){ - fail('Setting mountd port currently not supported on RedHat') + shellvar { 'rpc-mount-options': + ensure => present, + target => '/etc/sysconfig/nfs', + variable => 'MOUNTD_PORT', + value => $mountd_port, + notify => Service[$service_name], + } } include nfs::server::redhat::install, nfs::server::redhat::service - } diff --git a/spec/classes/server_redhat_spec.rb b/spec/classes/server_redhat_spec.rb index cb5ca94..99dc491 100644 --- a/spec/classes/server_redhat_spec.rb +++ b/spec/classes/server_redhat_spec.rb @@ -23,12 +23,10 @@ end end - context "setting mountd port" do - let(:params) {{ :mountd_port => 4711 }} + context "mountd params set" 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/) + should contain_shellvar('rpc-mount-options') #.with( 'ensure' => 'present' ) end end end From a9d79e8e48db004f85217d6e4611142600f9d5d1 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 22 Sep 2015 14:55:02 +0000 Subject: [PATCH 2/3] Add Gemfile.lock to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index acce3c2..68ed3cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ spec/fixtures/modules/* spec/fixtures/manifests/* *swp -.DS_Store \ No newline at end of file +.DS_Store +Gemfile.lock From 80bb90ed963c62b3ea08b3937fd76fa54c0f2c2c Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 22 Sep 2015 15:23:46 +0000 Subject: [PATCH 3/3] Future parser errors: Add operatingsystemmajrelease fact to rspec-puppet for future parser Test that operatingsystemmajrelease is defined first --- manifests/server/redhat.pp | 2 +- spec/classes/server_redhat_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/server/redhat.pp b/manifests/server/redhat.pp index 0a53e04..cd04ee8 100644 --- a/manifests/server/redhat.pp +++ b/manifests/server/redhat.pp @@ -4,7 +4,7 @@ $mountd_port = undef, $mountd_threads = 1 ) { - if $::operatingsystemmajrelease =~ /^7/ { + if ($::operatingsystemmajrelease == defined) and ($::operatingsystemmajrelease =~ /^7/) { $service_name = 'nfs-server' } else { $service_name = 'nfs' diff --git a/spec/classes/server_redhat_spec.rb b/spec/classes/server_redhat_spec.rb index 99dc491..914bcab 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', :operatingsystemmajrelease => '6'} } it do should contain_class('nfs::client::redhat') should contain_service('nfs').with( 'ensure' => 'running' ) @@ -9,7 +9,7 @@ end context "operatingsystemrelease => 7.1" do - let(:facts) { {:operatingsystemrelease => '7.1'} } + let(:facts) { {:operatingsystemrelease => '7.1', :operatingsystemmajrelease => '7'} } it do should contain_class('nfs::client::redhat') should contain_class('nfs::server::redhat::service')