Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vna/mods #33

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
$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"] ->
Class["::nfs::client::${osfamily}"] ->
Class['::nfs::client']
}
14 changes: 9 additions & 5 deletions manifests/client/debian.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
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,
$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
}
}
2 changes: 1 addition & 1 deletion manifests/client/mount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
) {

include nfs::client

Class["nfs::client"] -> Nfs::Client::Mount["$title"]

if $nfs::client::nfs_v4 == true {

Expand Down
15 changes: 9 additions & 6 deletions manifests/client/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
# 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,
$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
}
}
26 changes: 13 additions & 13 deletions manifests/mkdir.pp
Original file line number Diff line number Diff line change
@@ -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}"]
}
}
}
4 changes: 3 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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}":
Expand Down
5 changes: 3 additions & 2 deletions manifests/server/darwin.pp
Original file line number Diff line number Diff line change
@@ -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")
}
30 changes: 16 additions & 14 deletions manifests/server/debian.pp
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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'],
}
}
}
}
2 changes: 1 addition & 1 deletion manifests/server/export.pp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/export/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
) {

if $ensure != 'absent' {
$line = "${name} ${clients}\n"
$line = sprintf("%s %s\n", $name, join($clients, " "))

concat::fragment{
"${name}":
Expand Down
14 changes: 11 additions & 3 deletions manifests/server/nfs_v4/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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}":
Expand Down
14 changes: 9 additions & 5 deletions manifests/server/redhat.pp
Original file line number Diff line number Diff line change
@@ -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
}
}
19 changes: 10 additions & 9 deletions spec/classes/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion spec/defines/server_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down