Skip to content

Commit

Permalink
lint!
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjahn committed Dec 7, 2015
1 parent b1204f4 commit 41660ae
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ end
desc "Run syntax, lint, and spec tests."
task :test => [
:syntax,
# :lint,
:lint,
:spec,
]
6 changes: 3 additions & 3 deletions manifests/server/ads.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
$map_readonly = 'no',
$target_ou = 'Nix_Mashine') {

$krb5_user_package = $osfamily ? {
$krb5_user_package = $::osfamily ? {
'RedHat' => 'krb5-workstation',
default => 'krb5-user',
}

if $osfamily == 'RedHat' {
if $operatingsystemrelease =~ /^6\./ {
if $::osfamily == 'RedHat' {
if $::operatingsystemrelease =~ /^6\./ {
$winbind_package = 'samba-winbind'
} else {
$winbind_package = 'samba-common'
Expand Down
10 changes: 4 additions & 6 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# == Class samba::server::config
#
class samba::server::config {

file { '/etc/samba':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}

file { '/etc/samba/smb.conf':
Expand All @@ -17,5 +16,4 @@
require => [File['/etc/samba'], Class['samba::server::install']],
notify => Class['samba::server::service']
}

}
12 changes: 8 additions & 4 deletions manifests/server/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
default: { $service_name = 'samba' }
}
}
'Ubuntu': { $service_name = 'smbd'
$nmbd_name = 'nmbd' }
'Ubuntu': {
$service_name = 'smbd'
$nmbd_name = 'nmbd'
}
default: { $service_name = 'samba' }
}
}
'Gentoo': { $service_name = 'samba' }
'Archlinux': { $service_name = 'smbd'
$nmbd_name = 'nmbd' }
'Archlinux': {
$service_name = 'smbd'
$nmbd_name = 'nmbd'
}

# Currently Gentoo has $::osfamily = "Linux". This should change in
# Factor 1.7.0 <http://projects.puppetlabs.com/issues/17029>, so
Expand Down
17 changes: 8 additions & 9 deletions manifests/server/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
$enable = true
) inherits samba::server::params {

service { $service_name :
ensure => $ensure,
hasstatus => true,
hasrestart => true,
enable => $enable,
require => Class['samba::server::config']
service { $samba::server::params::service_name :
ensure => $ensure,
hasstatus => true,
hasrestart => true,
enable => $enable,
require => Class['samba::server::config']
}

if $nmbd_name != undef {
service { $nmbd_name :
if $samba::server::params::nmbd_name != undef {
service { $samba::server::params::nmbd_name :
ensure => $ensure,
hasrestart => false,
enable => $enable,
require => Class['samba::server::config'],
}
}

}
84 changes: 29 additions & 55 deletions manifests/server/share.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,39 @@
$context = $samba::server::context
$target = "target[. = '${name}']"

$section_changes = $ensure ? {
present => "set ${target} '${name}'",
default => "rm ${target} '${name}'",
}

augeas { "${name}-section":
incl => $incl,
lens => 'Samba.lns',
context => $context,
changes => $ensure ? {
present => "set ${target} '${name}'",
default => "rm ${target} '${name}'",
},
changes => $section_changes,
require => Class['samba::server::config'],
notify => Class['samba::server::service']
}

if $ensure == 'present' {
$changes = [
$available ? {
true => "set \"${target}/available\" yes",
false => "set \"${target}/available\" no",
default => "rm \"${target}/available\"",
},
true => "set \"${target}/available\" yes",
false => "set \"${target}/available\" no",
default => "rm \"${target}/available\"",
},
$browsable ? {
true => "set \"${target}/browsable\" yes",
false => "set \"${target}/browsable\" no",
default => "rm \"${target}/browsable\"",
true => "set \"${target}/browsable\" yes",
false => "set \"${target}/browsable\" no",
default => "rm \"${target}/browsable\"",
},
$comment ? {
default => "set \"${target}/comment\" '${comment}'",
'' => "rm \"${target}/comment\"",
default => "set \"${target}/comment\" '${comment}'",
'' => "rm \"${target}/comment\"",
},
$copy ? {
'' => "rm \"${target}/copy\"",
default => "set \"${target}/copy\" '${copy}'",
'' => "rm \"${target}/copy\"",
default => "set \"${target}/copy\" '${copy}'",
},
$create_mask ? {
'' => "rm \"${target}/create mask\"",
Expand Down Expand Up @@ -160,63 +162,35 @@
false => "set \"${target}/strict allocate\" no",
default => "rm \"${target}/strict allocate\"",
},
]

augeas { "${name}-changes":
incl => $incl,
lens => 'Samba.lns',
context => $context,
changes => $changes,
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}

augeas { "${name}-valid_users":
context => $context,
changes => $valid_users ? {
$valid_users ? {
'' => "rm \"${target}/valid users\"",
default => "set \"${target}/valid users\" '${valid_users}'",
},
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}

augeas { "${name}-op_locks":
context => $context,
changes => $op_locks ? {
$op_locks ? {
'' => "rm \"${target}/oplocks\"",
default => "set \"${target}/oplocks\" '${op_locks}'",
},
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}
augeas { "${name}-level2_oplocks":
context => $context,
changes => $level2_oplocks ? {
$level2_oplocks ? {
'' => "rm \"${target}/level2 oplocks\"",
default => "set \"${target}/level2 oplocks\" '${level2_oplocks}'",
},
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}
augeas { "${name}-veto_oplock_files":
context => $context,
changes => $veto_oplock_files ? {
$veto_oplock_files ? {
'' => "rm \"${target}/veto oplock files\"",
default => "set \"${target}/veto oplock files\" '${veto_oplock_files}'",
},
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}
augeas { "${name}-write_list":
context => $context,
changes => $write_list ? {
$write_list ? {
'' => "rm \"${target}/write list\"",
default => "set \"${target}/write list\" '${write_list}'",
},
]

augeas { "${name}-changes":
incl => $incl,
lens => 'Samba.lns',
context => $context,
changes => $changes,
require => Augeas["${name}-section"],
notify => Class['samba::server::service']
}

}
}
11 changes: 5 additions & 6 deletions manifests/server/winbind.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
$service_name = 'winbind'

service { $service_name:
ensure => $ensure,
hasstatus => true,
hasrestart => true,
enable => $enable,
require => Class['samba::server::config']
ensure => $ensure,
hasstatus => true,
hasrestart => true,
enable => $enable,
require => Class['samba::server::config']
}

}

0 comments on commit 41660ae

Please sign in to comment.