diff options
author | Adam Jahn <ajjahn@gmail.com> | 2012-08-24 12:47:46 -0400 |
---|---|---|
committer | Adam Jahn <ajjahn@gmail.com> | 2012-08-24 12:59:50 -0400 |
commit | c7768c8bdbb54b0237aa14c7a9830dac45596a14 (patch) | |
tree | a4e0e8f5ad910695b062b809ebda6861fbabb216 /manifests/share.pp | |
parent | 6f7c9d567d3a357f6ab58ce28acea7433908eab1 (diff) | |
download | puppet-samba-c7768c8bdbb54b0237aa14c7a9830dac45596a14.tar.gz puppet-samba-c7768c8bdbb54b0237aa14c7a9830dac45596a14.tar.bz2 |
share config options should be optional
Diffstat (limited to 'manifests/share.pp')
-rw-r--r-- | manifests/share.pp | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/manifests/share.pp b/manifests/share.pp index cebd4fa..a5ed122 100644 --- a/manifests/share.pp +++ b/manifests/share.pp @@ -1,25 +1,66 @@ -define samba::share($ensure=present, - $description, - $path, - $browsable, - $guestok="no", - $readonly="no" ) { +define samba::share($ensure = present, + $description = '', + $path = '', + $browsable = '', + $guestok = '', + $readonly = '') { $context = "/files/etc/samba/smb.conf" $target = "target[. = '${name}']" - augeas { "${name}": + augeas { "${name}-section": context => $context, changes => $ensure ? { - present => [ "set ${target} ${name}", - "set ${target}/comment ${description}", - "set ${target}/path ${path}", - "set ${target}/browsable ${browsable}", - "set ${target}/guestok ${guestok}", - "set ${target}/readonly ${readonly}" ], - default => ["rm ${target} ${name}"], + present => "set ${target} ${name}", + default => "rm ${target} ${name}", }, require => Class["samba::server::config"] } - + + if $ensure == "present" { + augeas { "${name}-comment": + context => $context, + changes => $description ? { + default => "set ${target}/comment ${description}", + '' => "rm ${target}/comment", + }, + require => Augeas["${name}-section"], + } + + augeas { "${name}-path": + context => $context, + changes => $path ? { + default => "set ${target}/path ${path}", + '' => "rm ${target}/path", + }, + require => Augeas["${name}-section"], + } + + augeas { "${name}-browsable": + context => $context, + changes => $browsable ? { + default => "set ${target}/browsable ${browsable}", + '' => "rm ${target}/browsable", + }, + require => Augeas["${name}-section"], + } + + augeas { "${name}-guestok": + context => $context, + changes => $guestok ? { + default => "set ${target}/guestok ${guestok}", + '' => "rm ${target}/guestok", + }, + require => Augeas["${name}-section"], + } + + augeas { "${name}-readonly": + context => $context, + changes => $readonly ? { + default => "set ${target}/readonly ${readonly}", + '' => "rm ${target}/readonly", + }, + require => Augeas["${name}-section"], + } + } } |