From 968117be0926164c57eda5653b9bf2f7e1c8f5b3 Mon Sep 17 00:00:00 2001 From: derdanne Date: Fri, 12 Dec 2014 12:23:28 +0100 Subject: [PATCH 1/2] added gentoo compatibility --- manifests/client/gentoo.pp | 10 +++++++++ manifests/client/gentoo/configure.pp | 19 ++++++++++++++++ manifests/client/gentoo/install.pp | 6 +++++ manifests/client/gentoo/service.pp | 7 ++++++ manifests/mkdir.pp | 3 ++- manifests/params.pp | 2 ++ manifests/server/configure.pp | 5 +++-- manifests/server/export/nfs_v4/bindmount.pp | 2 +- manifests/server/gentoo.pp | 14 ++++++++++++ manifests/server/gentoo/install.pp | 3 +++ manifests/server/gentoo/service.pp | 25 +++++++++++++++++++++ 11 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 manifests/client/gentoo.pp create mode 100644 manifests/client/gentoo/configure.pp create mode 100644 manifests/client/gentoo/install.pp create mode 100644 manifests/client/gentoo/service.pp create mode 100644 manifests/server/gentoo.pp create mode 100644 manifests/server/gentoo/install.pp create mode 100644 manifests/server/gentoo/service.pp diff --git a/manifests/client/gentoo.pp b/manifests/client/gentoo.pp new file mode 100644 index 0000000..3d1a747 --- /dev/null +++ b/manifests/client/gentoo.pp @@ -0,0 +1,10 @@ +class nfs::client::gentoo ( + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef +) { + + include nfs::client::gentoo::install, + nfs::client::gentoo::configure, + nfs::client::gentoo::service + +} diff --git a/manifests/client/gentoo/configure.pp b/manifests/client/gentoo/configure.pp new file mode 100644 index 0000000..d09835c --- /dev/null +++ b/manifests/client/gentoo/configure.pp @@ -0,0 +1,19 @@ +class nfs::client::gentoo::configure { + Augeas{ + require => Class['nfs::client::gentoo::install'] + } + + if $nfs::client::gentoo::nfs_v4 { + augeas { + '/etc/conf.d/nfs': + context => '/files/etc/conf.d/nfs', + changes => [ 'set NFS_NEEDED_SERVICES rpc.idmapd' ]; + '/etc/idmapd.conf': + context => '/files/etc/idmapd.conf/General', + lens => 'Puppet.lns', + incl => '/etc/idmapd.conf', + changes => ["set Domain ${nfs::client::gentoo::nfs_v4_idmap_domain}"]; + } + } + +} diff --git a/manifests/client/gentoo/install.pp b/manifests/client/gentoo/install.pp new file mode 100644 index 0000000..ca63d2f --- /dev/null +++ b/manifests/client/gentoo/install.pp @@ -0,0 +1,6 @@ +class nfs::client::gentoo::install { + + package { ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap']: + ensure => installed, + } +} diff --git a/manifests/client/gentoo/service.pp b/manifests/client/gentoo/service.pp new file mode 100644 index 0000000..0aa552a --- /dev/null +++ b/manifests/client/gentoo/service.pp @@ -0,0 +1,7 @@ +class nfs::client::gentoo::service { + + Service{ + require => Class['nfs::client::gentoo::configure'] + } + +} diff --git a/manifests/mkdir.pp b/manifests/mkdir.pp index 9192103..4ee0d45 100644 --- a/manifests/mkdir.pp +++ b/manifests/mkdir.pp @@ -10,7 +10,8 @@ file { "${name}": ensure => directory, - require => Exec["mkdir_recurse_${name}"] + require => Exec["mkdir_recurse_${name}"], + mode => "0777", } } diff --git a/manifests/params.pp b/manifests/params.pp index 02d0799..f50c403 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,6 +17,8 @@ fail('fail!11') } 'darwin':{ $osfamily = 'darwin' + } 'gentoo': { + $osfamily = 'gentoo' } default: { fail("OS: ${::operatingsystem} not supported") } diff --git a/manifests/server/configure.pp b/manifests/server/configure.pp index dbef395..be59f90 100644 --- a/manifests/server/configure.pp +++ b/manifests/server/configure.pp @@ -1,7 +1,8 @@ class nfs::server::configure { - concat {'/etc/exports': - require => Class["nfs::server::${nfs::server::osfamily}"] + concat {'/etc/exports': + require => Class["nfs::server::${nfs::server::osfamily}"], + ensure => present, } diff --git a/manifests/server/export/nfs_v4/bindmount.pp b/manifests/server/export/nfs_v4/bindmount.pp index 4cf354d..a79cb62 100644 --- a/manifests/server/export/nfs_v4/bindmount.pp +++ b/manifests/server/export/nfs_v4/bindmount.pp @@ -1,4 +1,4 @@ -define nfs::server::export::nfs_v4::bindmount ( +define nfs::server::export::nfs_v4::bindmount ( $ensure = 'mounted', $bind = $bind, $v4_export_name diff --git a/manifests/server/gentoo.pp b/manifests/server/gentoo.pp new file mode 100644 index 0000000..463fdc2 --- /dev/null +++ b/manifests/server/gentoo.pp @@ -0,0 +1,14 @@ +# Gentoo specifix stuff +class nfs::server::gentoo( + $nfs_v4 = false, + $nfs_v4_idmap_domain = undef +) { + + class{ 'nfs::client::gentoo': + nfs_v4 => $nfs_v4, + nfs_v4_idmap_domain => $nfs_v4_idmap_domain, + } + + include nfs::server::gentoo::install, nfs::server::gentoo::service + +} diff --git a/manifests/server/gentoo/install.pp b/manifests/server/gentoo/install.pp new file mode 100644 index 0000000..576ec53 --- /dev/null +++ b/manifests/server/gentoo/install.pp @@ -0,0 +1,3 @@ +class nfs::server::gentoo::install { + +} diff --git a/manifests/server/gentoo/service.pp b/manifests/server/gentoo/service.pp new file mode 100644 index 0000000..ebc3f56 --- /dev/null +++ b/manifests/server/gentoo/service.pp @@ -0,0 +1,25 @@ +class nfs::server::gentoo::service { + + if $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'], + } + } +} \ No newline at end of file From efe0cb85e2af16ffa2837914499fc3d2c33d66a4 Mon Sep 17 00:00:00 2001 From: derdanne Date: Fri, 12 Dec 2014 12:40:10 +0100 Subject: [PATCH 2/2] - added spec tests for gentoo --- spec/classes/client_gentoo_spec.rb | 25 +++++++++++++++++++++++++ spec/classes/client_spec.rb | 4 ++++ spec/classes/server_gentoo_spec.rb | 15 +++++++++++++++ spec/classes/server_spec.rb | 6 +++++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 spec/classes/client_gentoo_spec.rb create mode 100644 spec/classes/server_gentoo_spec.rb diff --git a/spec/classes/client_gentoo_spec.rb b/spec/classes/client_gentoo_spec.rb new file mode 100644 index 0000000..e397118 --- /dev/null +++ b/spec/classes/client_gentoo_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' +describe 'nfs::client::gentoo' do + + it do + should contain_class('nfs::client::gentoo') + should contain_class('nfs::client::gentoo::install') + should contain_class('nfs::client::gentoo::configure') + should contain_class('nfs::client::gentoo::service') + + should contain_package('net-nds/rpcbind') + should contain_package('net-fs/nfs-utils') + should contain_package('net-libs/libnfsidmap') + + + end + + context ":nfs_v4 => true" do + let(:params) {{ :nfs_v4 => true }} + it do + should contain_augeas('/etc/conf.d/nfs') + should contain_augeas('/etc/idmapd.conf') + end + end + +end diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb index 3dea98b..314750c 100644 --- a/spec/classes/client_spec.rb +++ b/spec/classes/client_spec.rb @@ -21,6 +21,10 @@ let(:facts) { {:operatingsystem => 'redhat', :osmajor => 6 } } it { should contain_class('nfs::client::redhat') } end + context "operatingsysten => gentoo" do + let(:facts) { {:operatingsystem => 'gentoo', } } + it { should contain_class('nfs::client::gentoo') } + end context "operatingsystem => darwin" do let(:facts) { {:operatingsystem => 'darwin', } } it do diff --git a/spec/classes/server_gentoo_spec.rb b/spec/classes/server_gentoo_spec.rb new file mode 100644 index 0000000..633de53 --- /dev/null +++ b/spec/classes/server_gentoo_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' +describe 'nfs::server::gentoo' do + + it do + should contain_class('nfs::client::gentoo') + should contain_service('nfs').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 +end \ No newline at end of file diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index f98c0c0..c9ffff0 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -6,7 +6,7 @@ should contain_concat__fragment('nfs_exports_header').with( 'target' => '/etc/exports' ) end context "nfs_v4 => true" do - let(:params) { {:nfs_v4 => true, } } + let(:params) { {:nfs_v4 => true, } } it do should contain_concat__fragment('nfs_exports_root').with( 'target' => '/etc/exports' ) should contain_file('/export').with( 'ensure' => 'directory' ) @@ -33,6 +33,10 @@ let(:facts) { {:operatingsystem => 'redhat', :concat_basedir => '/tmp', :osmajor => 6, } } it { should contain_class('nfs::server::redhat') } end + context "operatingsysten => gentoo" do + let(:facts) { {:operatingsystem => 'gentoo', :concat_basedir => '/tmp',} } + it { should contain_class('nfs::server::gentoo') } + end context "operatingsysten => darwin" do let(:facts) { {:operatingsystem => 'darwin'} } it do