diff options
-rw-r--r-- | manifests/server.pp | 29 | ||||
-rw-r--r-- | manifests/server/config.pp | 22 | ||||
-rw-r--r-- | manifests/share.pp | 3 |
3 files changed, 36 insertions, 18 deletions
diff --git a/manifests/server.pp b/manifests/server.pp index 48a4fef..1f1702c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -2,12 +2,23 @@ class samba::server($workgroup = pcch) { include samba::server::install include samba::server::config include samba::server::service - - augeas { global: - context => "/files/etc/samba/smb.conf", - changes => [ - "set target[. = 'global']/workgroup $workgroup" - ], - require => Class["samba::server::config"] - } -}
\ No newline at end of file + + $context = "/files/etc/samba/smb.conf" + $target = "target[. = 'global']" + + augeas { 'global-section': + context => $context, + changes => "set ${target} global", + require => Class["samba::server::config"] + } + + augeas { 'global-workgroup': + context => $context, + changes => $workgroup ? { + default => "set ${target}/workgroup $workgroup", + '' => "rm ${target}/workgroup", + }, + require => Augeas['global-section'], + } + +} diff --git a/manifests/server/config.pp b/manifests/server/config.pp index e9b1ed9..9699857 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -1,11 +1,19 @@ class samba::server::config { - + + file { "/etc/samba": + ensure => directory, + owner => "root", + group => "root", + mode => 0755, + } + file { "/etc/samba/smb.conf": - ensure => $ensure, - owner => root, - group => root, - require => Class["samba::server::install"], + ensure => present, + owner => "root", + group => "root", + mode => 0644, + require => [File["/etc/samba"], Class["samba::server::install"]], notify => Class["samba::server::service"] } - -}
\ No newline at end of file + +} diff --git a/manifests/share.pp b/manifests/share.pp index 5f05ad6..cebd4fa 100644 --- a/manifests/share.pp +++ b/manifests/share.pp @@ -5,11 +5,10 @@ define samba::share($ensure=present, $guestok="no", $readonly="no" ) { - $share = $name $context = "/files/etc/samba/smb.conf" $target = "target[. = '${name}']" - augeas { "${share}": + augeas { "${name}": context => $context, changes => $ensure ? { present => [ "set ${target} ${name}", |