Skip to content

Commit

Permalink
Merge pull request arioch#1 from derdanne/gentoo-compatibility
Browse files Browse the repository at this point in the history
Gentoo compatibility
  • Loading branch information
dwerder committed Dec 12, 2014
2 parents d6294e8 + efe0cb8 commit 95a8987
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 5 deletions.
10 changes: 10 additions & 0 deletions manifests/client/gentoo.pp
Original file line number Diff line number Diff line change
@@ -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

}
19 changes: 19 additions & 0 deletions manifests/client/gentoo/configure.pp
Original file line number Diff line number Diff line change
@@ -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}"];
}
}

}
6 changes: 6 additions & 0 deletions manifests/client/gentoo/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class nfs::client::gentoo::install {

package { ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap']:
ensure => installed,
}
}
7 changes: 7 additions & 0 deletions manifests/client/gentoo/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class nfs::client::gentoo::service {

Service{
require => Class['nfs::client::gentoo::configure']
}

}
3 changes: 2 additions & 1 deletion manifests/mkdir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
file {
"${name}":
ensure => directory,
require => Exec["mkdir_recurse_${name}"]
require => Exec["mkdir_recurse_${name}"],
mode => "0777",
}

}
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
fail('fail!11')
} 'darwin':{
$osfamily = 'darwin'
} 'gentoo': {
$osfamily = 'gentoo'
} default: {
fail("OS: ${::operatingsystem} not supported")
}
Expand Down
5 changes: 3 additions & 2 deletions manifests/server/configure.pp
Original file line number Diff line number Diff line change
@@ -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,
}


Expand Down
2 changes: 1 addition & 1 deletion manifests/server/export/nfs_v4/bindmount.pp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions manifests/server/gentoo.pp
Original file line number Diff line number Diff line change
@@ -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

}
3 changes: 3 additions & 0 deletions manifests/server/gentoo/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class nfs::server::gentoo::install {

}
25 changes: 25 additions & 0 deletions manifests/server/gentoo/service.pp
Original file line number Diff line number Diff line change
@@ -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'],
}
}
}
25 changes: 25 additions & 0 deletions spec/classes/client_gentoo_spec.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions spec/classes/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/server_gentoo_spec.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand All @@ -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
Expand Down

0 comments on commit 95a8987

Please sign in to comment.