Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 426ad8f

Browse files
committedOct 12, 2015
clone debian config to ubuntu
1 parent 7b5b8ae commit 426ad8f

12 files changed

+189
-9
lines changed
 

‎manifests/client/ubuntu.pp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class nfs::client::ubuntu (
2+
$nfs_v4 = false,
3+
$nfs_v4_idmap_domain = undef
4+
) {
5+
6+
include nfs::client::ubuntu::install,
7+
nfs::client::ubuntu::configure,
8+
nfs::client::ubuntu::service
9+
10+
}

‎manifests/client/ubuntu/configure.pp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class nfs::client::ubuntu::configure {
2+
Augeas{
3+
require => Class['nfs::client::ubuntu::install']
4+
}
5+
6+
if $nfs::client::ubuntu::nfs_v4 {
7+
augeas {
8+
'/etc/default/nfs-common':
9+
context => '/files/etc/default/nfs-common',
10+
changes => [ 'set NEED_IDMAPD yes', ];
11+
'/etc/idmapd.conf':
12+
context => '/files/etc/idmapd.conf/General',
13+
lens => 'Puppet.lns',
14+
incl => '/etc/idmapd.conf',
15+
changes => ["set Domain ${nfs::client::ubuntu::nfs_v4_idmap_domain}"],
16+
}
17+
}
18+
19+
}

‎manifests/client/ubuntu/install.pp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class nfs::client::ubuntu::install {
2+
3+
package { 'rpcbind':
4+
ensure => installed,
5+
}
6+
7+
package { ['nfs-common', 'nfs4-acl-tools']:
8+
ensure => installed,
9+
}
10+
11+
}

‎manifests/client/ubuntu/service.pp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class nfs::client::ubuntu::service {
2+
Service {
3+
require => Class['nfs::client::ubuntu::configure']
4+
}
5+
6+
service { 'rpcbind':
7+
ensure => running,
8+
enable => true,
9+
hasstatus => false,
10+
}
11+
12+
if $nfs::client::ubuntu::nfs_v4 {
13+
service { 'idmapd':
14+
ensure => running,
15+
subscribe => Augeas['/etc/idmapd.conf', '/etc/default/nfs-common'],
16+
}
17+
} else {
18+
service { 'idmapd': ensure => stopped, }
19+
}
20+
}

‎manifests/params.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
# Somehow the ::osfamily fact doesnt exist on some systems
1010

1111
case $::operatingsystem {
12-
'centos', 'redhat', 'scientific', 'fedora', 'SLC', 'OracleLinux', 'Amazon' : { $osfamily = 'redhat' }
13-
'debian', 'Ubuntu' : { $osfamily = 'debian' }
14-
'windows' : { fail('fail!11') }
15-
'darwin' : { $osfamily = 'darwin' }
16-
'gentoo' : { $osfamily = 'gentoo' }
17-
default : { fail("OS: ${::operatingsystem} not supported") }
12+
'CentOS', 'RedHat', 'scientific', 'Fedora', 'SLC', 'OracleLinux', 'Amazon' : { $osfamily = 'redhat' }
13+
'Debian' : { $osfamily = 'debian' }
14+
'Ubuntu' : { $osfamily = 'ubuntu' }
15+
'darwin' : { $osfamily = 'darwin' }
16+
'gentoo' : { $osfamily = 'gentoo' }
17+
default : { fail("OS: ${::operatingsystem} not supported") }
1818
}
1919
}

‎manifests/server/ubuntu.pp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Debian specifix stuff
2+
class nfs::server::ubuntu(
3+
$nfs_v4 = false,
4+
$nfs_v4_idmap_domain = undef,
5+
$mountd_port = undef,
6+
$mountd_threads = 1,
7+
$service_manage = true,
8+
) {
9+
10+
if !defined(Class['nfs::client::ubuntu']) {
11+
class{ 'nfs::client::ubuntu':
12+
nfs_v4 => $nfs_v4,
13+
nfs_v4_idmap_domain => $nfs_v4_idmap_domain,
14+
}
15+
}
16+
17+
if ($mountd_port != undef){
18+
shellvar { 'rpc-mount-options':
19+
ensure => present,
20+
target => '/etc/default/nfs-kernel-server',
21+
variable => 'RPCMOUNTDOPTS',
22+
value => "--manage-gids --port ${mountd_port} --num-threads ${mountd_threads}",
23+
}
24+
25+
if $service_manage {
26+
Shellvar['rpc-mount-options'] ~> Service['nfs-kernel-server']
27+
}
28+
}
29+
30+
include nfs::server::ubuntu::install, nfs::server::ubuntu::service
31+
}

‎manifests/server/ubuntu/install.pp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class nfs::server::ubuntu::install {
2+
3+
package { 'nfs-kernel-server':
4+
ensure => installed
5+
}
6+
7+
}

‎manifests/server/ubuntu/service.pp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class nfs::server::ubuntu::service {
2+
3+
if $nfs::server::ubuntu::service_manage {
4+
if $nfs::server::ubuntu::nfs_v4 == true {
5+
service {'nfs-kernel-server':
6+
ensure => running,
7+
enable => true,
8+
hasrestart => true,
9+
hasstatus => true,
10+
require => Package['nfs-kernel-server'],
11+
subscribe => [ Concat['/etc/exports'], Augeas['/etc/idmapd.conf','/etc/default/nfs-common'] ],
12+
}
13+
} else {
14+
service {'nfs-kernel-server':
15+
ensure => running,
16+
enable => true,
17+
hasrestart => true,
18+
hasstatus => true,
19+
require => Package['nfs-kernel-server'],
20+
subscribe => Concat['/etc/exports'],
21+
}
22+
}
23+
24+
Package['rpcbind'] -> Service['rpcbind']
25+
}
26+
}

‎spec/classes/client_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'nfs::client' do
44
context "operatingsysten => ubuntu" do
55
let(:facts) { {:operatingsystem => 'ubuntu', } }
6-
it { should contain_class('nfs::client::debian') }
6+
it { should contain_class('nfs::client::ubuntu') }
77
end
88
context "operatingsysten => debian" do
99
let(:facts) { {:operatingsystem => 'debian', } }

‎spec/classes/client_ubuntu_spec.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
describe 'nfs::client::ubuntu' do
3+
4+
it do
5+
should contain_class('nfs::client::ubuntu::install')
6+
should contain_class('nfs::client::ubuntu::configure')
7+
should contain_class('nfs::client::ubuntu::service')
8+
9+
should contain_service('rpcbind').with(
10+
'ensure' => 'running'
11+
)
12+
13+
should contain_service('idmapd').with(
14+
'ensure' => 'stopped'
15+
)
16+
should contain_package('nfs-common')
17+
should contain_package('rpcbind')
18+
19+
should contain_package('nfs4-acl-tools')
20+
end
21+
context ":nfs_v4 => true" do
22+
let(:params) {{ :nfs_v4 => true }}
23+
it do
24+
should contain_augeas('/etc/idmapd.conf')
25+
should contain_service('idmapd').with(
26+
'ensure' => 'running'
27+
)
28+
end
29+
end
30+
31+
end

‎spec/classes/server_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
context "operatingsysten => ubuntu" do
1717
let(:facts) { {:operatingsystem => 'ubuntu', :concat_basedir => '/tmp', } }
18-
it { should contain_class('nfs::server::debian') }
18+
it { should contain_class('nfs::server::ubuntu') }
1919
end
2020

2121
context "operatingsysten => ubuntu with params for mountd" do
2222
let(:facts) { {:operatingsystem => 'ubuntu', :concat_basedir => '/tmp', } }
2323
let(:params) {{ :mountd_port => '4711', :mountd_threads => '99' }}
2424

2525
it do
26-
should contain_class('nfs::server::debian').with( 'mountd_port' => '4711', 'mountd_threads' => '99' )
26+
should contain_class('nfs::server::ubuntu').with( 'mountd_port' => '4711', 'mountd_threads' => '99' )
2727
end
2828
end
2929

‎spec/classes/server_ubuntu_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
require 'spec_helper'
3+
describe 'nfs::server::ubuntu', :type => :class do
4+
it do
5+
should contain_class('nfs::client::ubuntu')
6+
should contain_class('nfs::server::ubuntu::service')
7+
should contain_package('nfs-kernel-server')
8+
should contain_service('nfs-kernel-server').with( 'ensure' => 'running' )
9+
end
10+
context ":nfs_v4 => true" do
11+
let(:params) {{ :nfs_v4 => true }}
12+
it do
13+
should contain_service('idmapd').with( 'ensure' => 'running' )
14+
end
15+
16+
end
17+
context "mountd params set" do
18+
let(:params) {{ :mountd_port => '4711' }}
19+
it do
20+
should contain_shellvar('rpc-mount-options') #.with( 'ensure' => 'present' )
21+
end
22+
23+
end
24+
end
25+

0 commit comments

Comments
 (0)
This repository has been archived.