From 08c7b8dfbb4297fabfc9a15619ff4461a871eac2 Mon Sep 17 00:00:00 2001 From: Christian Depner Date: Mon, 11 Nov 2013 09:24:01 +0100 Subject: The parameter is now settable --- manifests/server.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index bc1e3d7..9e5ee2e 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -2,7 +2,8 @@ class samba::server($interfaces = '', $security = '', $server_string = '', $unix_password_sync = '', - $workgroup = '') { + $workgroup = '', + $bind_interfaces_only = 'yes',) { include samba::server::install include samba::server::config @@ -21,7 +22,7 @@ class samba::server($interfaces = '', set_samba_option { 'interfaces': value => $interfaces; - 'bind interfaces only': value => 'yes'; + 'bind interfaces only': value => $bind_interfaces_only; 'security': value => $security; 'server string': value => $server_string; 'unix password sync': value => $unix_password_sync; -- cgit v1.2.3 From e9be6b324468dd380c501ba71fe297d9d92da50a Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 3 Jan 2014 14:31:55 +0100 Subject: FIX: augeas runtime optimization (~4 sec per augeas resource) --- manifests/server.pp | 13 +++- manifests/server/share.pp | 188 ++++++++++++---------------------------------- 2 files changed, 60 insertions(+), 141 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index bc1e3d7..0dfda00 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -8,10 +8,13 @@ class samba::server($interfaces = '', include samba::server::config include samba::server::service - $context = '/files/etc/samba/smb.conf' - $target = "target[. = 'global']" + $incl = '/etc/samba/smb.conf' + $context = "/files/etc/samba/smb.conf" + $target = "target[. = 'global']" augeas { 'global-section': + incl => $incl, + lens => 'Samba.lns', context => $context, changes => "set ${target} global", require => Class['samba::server::config'], @@ -30,14 +33,18 @@ class samba::server($interfaces = '', } define set_samba_option ( $value = '', $signal = 'samba::server::service' ) { + $incl = $samba::server::incl $context = $samba::server::context - $target = $samba::server::target + $target = $samba::server::target + $changes = $value ? { default => "set \"${target}/$name\" \"$value\"", '' => "rm ${target}/$name", } augeas { "samba-$name": + incl => $incl, + lens => 'Samba.lns', context => $context, changes => $changes, require => Augeas['global-section'], diff --git a/manifests/server/share.pp b/manifests/server/share.pp index b4eb02f..b8e508c 100644 --- a/manifests/server/share.pp +++ b/manifests/server/share.pp @@ -16,11 +16,13 @@ define samba::server::share($ensure = present, $public = '', $writable = '', $printable = '') { - + $incl = $samba::server::incl $context = $samba::server::context - $target = "target[. = '${name}']" + $target = "target[. = '${name}']" augeas { "${name}-section": + incl => $incl, + lens => 'Samba.lns', context => $context, changes => $ensure ? { present => "set ${target} '${name}'", @@ -31,179 +33,89 @@ define samba::server::share($ensure = present, } if $ensure == 'present' { - augeas { "${name}-browsable": - context => $context, - changes => $browsable ? { - true => "set ${target}/browsable yes", - false => "set ${target}/browsable no", - default => "rm ${target}/browsable", + $changes = [ + $browsable ? { + true => "set \"${target}/browsable\" yes", + false => "set \"${target}/browsable\" no", + default => "rm \"${target}/browsable\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-comment": - context => $context, - changes => $comment ? { - default => "set ${target}/comment '${comment}'", - '' => "rm ${target}/comment", + $comment ? { + default => "set \"${target}/comment\" '${comment}'", + '' => "rm \"${target}/comment\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-copy": - context => $context, - changes => $copy ? { - default => "set ${target}/copy '${copy}'", - '' => "rm ${target}/copy", + $copy ? { + default => "set \"${target}/copy\" '${copy}'", + '' => "rm \"${target}/copy\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-create_mask": - context => $context, - changes => $create_mask ? { + $create_mask ? { default => "set \"${target}/create mask\" '${create_mask}'", - '' => "rm \"${target}/create mask\"", + '' => "rm \"${target}/create mask\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-directory_mask": - context => $context, - changes => $directory_mask ? { + $directory_mask ? { default => "set \"${target}/directory mask\" '${directory_mask}'", - '' => "rm \"${target}/directory mask\"", + '' => "rm \"${target}/directory mask\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-force_create_mask": - context => $context, - changes => $force_create_mask ? { + $force_create_mask ? { default => "set \"${target}/force create mask\" '${force_create_mask}'", - '' => "rm \"${target}/force create mask\"", + '' => "rm \"${target}/force create mask\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-force_directory_mask": - context => $context, - changes => $force_directory_mask ? { + $force_directory_mask ? { default => "set \"${target}/force directory mask\" '${force_directory_mask}'", - '' => "rm \"${target}/force directory mask\"", + '' => "rm \"${target}/force directory mask\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-force_group": - context => $context, - changes => $force_group ? { + $force_group ? { default => "set \"${target}/force group\" '${force_group}'", - '' => "rm \"${target}/force group\"", + '' => "rm \"${target}/force group\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-force_user": - context => $context, - changes => $force_user ? { + $force_user ? { default => "set \"${target}/force user\" '${force_user}'", - '' => "rm \"${target}/force user\"", + '' => "rm \"${target}/force user\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-guest_account": - context => $context, - changes => $guest_account ? { + $guest_account ? { default => "set \"${target}/guest account\" '${guest_account}'", - '' => "rm \"${target}/guest account\"", + '' => "rm \"${target}/guest account\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-guest_ok": - context => $context, - changes => $guest_ok ? { + $guest_ok ? { true => "set \"${target}/guest ok\" yes", false => "set \"${target}/guest ok\" no", - default => "rm \"${target}/guest ok\"", + default => "rm \"${target}/guest ok\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-guest_only": - context => $context, - changes => $guest_only ? { + $guest_only ? { true => "set \"${target}/guest only\" yes", false => "set \"${target}/guest only\" no", - default => "rm \"${target}/guest only\"", + default => "rm \"${target}/guest only\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-path": - context => $context, - changes => $path ? { + $path ? { default => "set ${target}/path '${path}'", - '' => "rm ${target}/path", + '' => "rm ${target}/path", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-read_only": - context => $context, - changes => $read_only ? { + $read_only ? { true => "set \"${target}/read only\" yes", false => "set \"${target}/read only\" no", - default => "rm \"${target}/read_only\"", + default => "rm \"${target}/read_only\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-public": - context => $context, - changes => $public ? { + $public ? { true => "set \"${target}/public\" yes", false => "set \"${target}/public\" no", - default => "rm \"${target}/public\"", + default => "rm \"${target}/public\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-writable": - context => $context, - changes => $writable ? { + $writable ? { true => "set \"${target}/writable\" yes", false => "set \"${target}/writable\" no", - default => "rm \"${target}/writable\"", + default => "rm \"${target}/writable\"", }, - require => Augeas["${name}-section"], - notify => Class['samba::server::service'] - } - - augeas { "${name}-printable": - context => $context, - changes => $printable ? { + $printable ? { true => "set \"${target}/printable\" yes", false => "set \"${target}/printable\" no", - default => "rm \"${target}/printable\"", + default => "rm \"${target}/printable\"", }, + ] + + augeas { "${name}-changes": + incl => $incl, + lens => 'Samba.lns', + context => $context, + changes => $changes, require => Augeas["${name}-section"], notify => Class['samba::server::service'] } -- cgit v1.2.3 From 8bf623bca5a1e9d5da1ed05a8a9cb2a773ee55fb Mon Sep 17 00:00:00 2001 From: jonoterc Date: Thu, 10 Oct 2013 17:26:29 -0400 Subject: enabling installation of samba account checking/creation shell scripts --- manifests/server.pp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 0dfda00..996149f 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -30,6 +30,24 @@ class samba::server($interfaces = '', 'unix password sync': value => $unix_password_sync; 'workgroup': value => $workgroup; } + + file {'check_samba_user': + # script checks to see if a samba account exists for a given user + path => '/sbin/check_samba_user', + owner => root, + group => root, + mode => "0755", + content => template("${module_name}/check_samba_user"), + } + + file {'add_samba_user': + # script creates a new samba account for a given user and password + path => '/sbin/add_samba_user', + owner => root, + group => root, + mode => "0755", + content => template("${module_name}/add_samba_user"), + } } define set_samba_option ( $value = '', $signal = 'samba::server::service' ) { -- cgit v1.2.3 From f321b3a1e0fbed665ef92776dffb1abb064a9f84 Mon Sep 17 00:00:00 2001 From: Vladislav Nazarenko Date: Fri, 17 Jan 2014 13:55:55 +0100 Subject: moved set_samba_option to own file an renamed it to samba::server::option --- manifests/server.pp | 22 +--------------------- manifests/server/ads.pp | 30 ++++++++++++++++-------------- manifests/server/option.pp | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 manifests/server/option.pp (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 2e4c2d9..7003057 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -22,8 +22,7 @@ class samba::server($interfaces = '', notify => Class['samba::server::service'] } - - set_samba_option { + samba::server::option { 'interfaces': value => $interfaces; 'bind interfaces only': value => $bind_interfaces_only; 'security': value => $security; @@ -49,24 +48,5 @@ class samba::server($interfaces = '', mode => "0755", content => template("${module_name}/add_samba_user"), } -} - -define set_samba_option ( $value = '', $signal = 'samba::server::service' ) { - $incl = $samba::server::incl - $context = $samba::server::context - $target = $samba::server::target - - $changes = $value ? { - default => "set \"${target}/$name\" \"$value\"", - '' => "rm ${target}/$name", - } - augeas { "samba-$name": - incl => $incl, - lens => 'Samba.lns', - context => $context, - changes => $changes, - require => Augeas['global-section'], - notify => Class[$signal] - } } diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp index cadfee0..3d44af6 100644 --- a/manifests/server/ads.pp +++ b/manifests/server/ads.pp @@ -49,21 +49,23 @@ class samba::server::ads($ensure = present, include samba::server::config include samba::server::winbind - $signal = 'samba::server::winbind' + # notify winbind + samba::server::option { + 'realm': value => $realm, + notify => Class['Samba::Server::Winbind']; + 'winbind uid': value => $winbind_uid, + notify => Class['Samba::Server::Winbind']; + 'winbind gid': value => $winbind_gid, + notify => Class['Samba::Server::Winbind']; + 'winbind enum groups': value => $winbind_enum_groups, + notify => Class['Samba::Server::Winbind']; + 'winbind enum users': value => $winbind_enum_users, + notify => Class['Samba::Server::Winbind']; + 'winbind use default domain': value => $winbind_use_default_domain, + notify => Class['Samba::Server::Winbind']; + } - set_samba_option { - 'realm': value => $realm, - signal => $signal; - 'winbind uid': value => $winbind_uid, - signal => $signal; - 'winbind gid': value => $winbind_gid, - signal => $signal; - 'winbind enum groups': value => $winbind_enum_groups, - signal => $signal; - 'winbind enum users': value => $winbind_enum_users, - signal => $signal; - 'winbind use default domain': value => $winbind_use_default_domain, - signal => $signal; + samba::server::option { 'acl group control': value => $acl_group_control; 'map acl inherit': value => $map_acl_inherit; 'inherit acls': value => $inherit_acls; diff --git a/manifests/server/option.pp b/manifests/server/option.pp new file mode 100644 index 0000000..36968fc --- /dev/null +++ b/manifests/server/option.pp @@ -0,0 +1,19 @@ +define samba::server::option ( $value = '' ) { + $incl = $samba::server::incl + $context = $samba::server::context + $target = $samba::server::target + + $changes = $value ? { + default => "set \"${target}/$name\" \"$value\"", + '' => "rm ${target}/$name", + } + + augeas { "samba-$name": + incl => $incl, + lens => 'Samba.lns', + context => $context, + changes => $changes, + require => Augeas['global-section'], + notify => Class['Samba::Server::Service'] + } +} \ No newline at end of file -- cgit v1.2.3 From e369e9879f82dc455b6cc5c116768f21606fab8b Mon Sep 17 00:00:00 2001 From: Adrian Joian Date: Sun, 26 Jan 2014 10:43:19 +0100 Subject: adding several minor options to server.pp and shares.pp --- manifests/server.pp | 14 ++++++++++++++ manifests/server/share.pp | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 7003057..31589e0 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -3,6 +3,13 @@ class samba::server($interfaces = '', $server_string = '', $unix_password_sync = '', $workgroup = '', + $socket_options = '', + $deadtime = '', + $keepalive = '', + $load_printers = '', + $printing = '', + $printcap_name = '', + $disable_spoolss = '', $bind_interfaces_only = 'yes',) { include samba::server::install @@ -29,6 +36,13 @@ class samba::server($interfaces = '', 'server string': value => $server_string; 'unix password sync': value => $unix_password_sync; 'workgroup': value => $workgroup; + 'socket_options': value => $socket_options; + 'deadtime': value => $deadtime; + 'keepalive': value => $keepalive; + 'load_printers': value => $load_printers; + 'printing': value => $printing; + 'printcap_name': value => $printcap_name; + 'disable_spoolss': value => $disable_spoolss; } file {'check_samba_user': diff --git a/manifests/server/share.pp b/manifests/server/share.pp index 2233d45..b7d451f 100644 --- a/manifests/server/share.pp +++ b/manifests/server/share.pp @@ -1,4 +1,5 @@ define samba::server::share($ensure = present, + $available = '', $browsable = '', $comment = '', $copy = '', @@ -22,7 +23,7 @@ define samba::server::share($ensure = present, $printable = '', $valid_users = '', ) { - + $incl = $samba::server::incl $context = $samba::server::context $target = "target[. = '${name}']" @@ -41,6 +42,11 @@ define samba::server::share($ensure = present, if $ensure == 'present' { $changes = [ + $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", -- cgit v1.2.3 From 30ba71f6c8316e7f8f2336949a4d40c2b00c5989 Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Sat, 11 Apr 2015 13:32:43 -0400 Subject: lint formatting --- manifests/server.pp | 8 ++++---- manifests/server/ads.pp | 14 +++++++------- manifests/server/option.pp | 6 +++--- manifests/server/service.pp | 10 +++++----- manifests/server/user.pp | 20 +++++++++----------- 5 files changed, 28 insertions(+), 30 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 31589e0..09a1b27 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -17,8 +17,8 @@ class samba::server($interfaces = '', include samba::server::service $incl = '/etc/samba/smb.conf' - $context = "/files/etc/samba/smb.conf" - $target = "target[. = 'global']" + $context = '/files/etc/samba/smb.conf' + $target = 'target[. = 'global']' augeas { 'global-section': incl => $incl, @@ -50,7 +50,7 @@ class samba::server($interfaces = '', path => '/sbin/check_samba_user', owner => root, group => root, - mode => "0755", + mode => '0755', content => template("${module_name}/check_samba_user"), } @@ -59,7 +59,7 @@ class samba::server($interfaces = '', path => '/sbin/add_samba_user', owner => root, group => root, - mode => "0755", + mode => '0755', content => template("${module_name}/add_samba_user"), } diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp index 3d44af6..0b7e2a7 100644 --- a/manifests/server/ads.pp +++ b/manifests/server/ads.pp @@ -30,7 +30,7 @@ class samba::server::ads($ensure = present, default => 'krb5-user', } - if $osfamily == "RedHat" { + if $osfamily == 'RedHat' { if $operatingsystemrelease =~ /^6\./ { $winbind_package = 'samba-winbind' } else { @@ -82,10 +82,10 @@ class samba::server::ads($ensure = present, $changes=$nsswitch ? { true => [ - "set database[. = 'passwd']/service[1] compat", - "set database[. = 'passwd']/service[2] winbind", - "set database[. = 'group']/service[1] compat", - "set database[. = 'group']/service[2] winbind", + 'set database[. = 'passwd']/service[1] compat', + 'set database[. = 'passwd']/service[2] winbind', + 'set database[. = 'group']/service[1] compat', + 'set database[. = 'group']/service[2] winbind', ], false => [ "rm /files/${nss_file}/database[. = 'passwd']/service[. = 'winbind']", @@ -103,7 +103,7 @@ class samba::server::ads($ensure = present, path => '/sbin/verify_active_directory', owner => root, group => root, - mode => "0755", + mode => '0755', content => template("${module_name}/verify_active_directory.erb"), require => [ Package[$krb5_user_package, $winbind_package, 'expect'], Augeas['samba-realm', 'samba-security', 'samba-winbind enum users', @@ -116,7 +116,7 @@ class samba::server::ads($ensure = present, path => '/sbin/configure_active_directory', owner => root, group => root, - mode => "0755", + mode => '0755', content => template("${module_name}/configure_active_directory.erb"), require => [ Package[$krb5_user_package, $winbind_package, 'expect'], Augeas['samba-realm', 'samba-security', 'samba-winbind enum users', diff --git a/manifests/server/option.pp b/manifests/server/option.pp index 699985d..0b34edb 100644 --- a/manifests/server/option.pp +++ b/manifests/server/option.pp @@ -4,11 +4,11 @@ define samba::server::option ( $value = '' ) { $target = $samba::server::target $changes = $value ? { - '' => "rm ${target}/$name", - default => "set \"${target}/$name\" \"$value\"", + '' => "rm ${target}/${name}", + default => "set \"${target}/${name}\" \"${value}\"", } - augeas { "samba-$name": + augeas { "samba-${name}": incl => $incl, lens => 'Samba.lns', context => $context, diff --git a/manifests/server/service.pp b/manifests/server/service.pp index 9ad5fb0..fdd9104 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -7,8 +7,8 @@ class samba::server::service ($ensure = running, $enable = true) { 'Debian': { case $::operatingsystem{ 'Debian': { $service_name = 'samba' } - 'Ubuntu': { $service_name = 'smbd'} - default: { $service_name='samba'} + 'Ubuntu': { $service_name = 'smbd' } + default: { $service_name = 'samba' } } } 'Gentoo': { $service_name = 'samba' } @@ -20,13 +20,13 @@ class samba::server::service ($ensure = running, $enable = true) { 'Linux': { case $::operatingsystem { 'Gentoo': { $service_name = 'samba' } - default: { fail("$::operatingsystem is not supported by this module.") } + default: { fail("${::operatingsystem} is not supported by this module.") } } } - default: { fail("$::osfamily is not supported by this module.") } + default: { fail("${::osfamily} is not supported by this module.") } } - service { "$service_name" : + service { $service_name : ensure => $ensure, hasstatus => true, hasrestart => true, diff --git a/manifests/server/user.pp b/manifests/server/user.pp index 2cffe3b..e3d84cc 100644 --- a/manifests/server/user.pp +++ b/manifests/server/user.pp @@ -1,13 +1,11 @@ define samba::server::user( - $user_name = $name , - $password , - ) { - exec { "add smb account for ${user_name}": - command => "/sbin/add_samba_user '${user_name}' '${password}'" , - unless => "/sbin/check_samba_user '${user_name}'" , - require => [ - User["${user_name}"] - ] , - notify => Class['samba::server::service'] - } + $password, + $user_name = $name, +) { + exec { "add smb account for ${user_name}": + command => "/sbin/add_samba_user '${user_name}' '${password}'" , + unless => "/sbin/check_samba_user '${user_name}'" , + require => [ User[$user_name] ], + notify => Class['samba::server::service'] + } } -- cgit v1.2.3 From 0b8794e9a6b01d018cf81f7500f07891e66c9220 Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Sat, 11 Apr 2015 15:51:50 -0400 Subject: fix syntax error --- manifests/server.pp | 2 +- manifests/server/ads.pp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 09a1b27..9eace3d 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -18,7 +18,7 @@ class samba::server($interfaces = '', $incl = '/etc/samba/smb.conf' $context = '/files/etc/samba/smb.conf' - $target = 'target[. = 'global']' + $target = 'target[. = "global"]' augeas { 'global-section': incl => $incl, diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp index 0b7e2a7..781a6a9 100644 --- a/manifests/server/ads.pp +++ b/manifests/server/ads.pp @@ -82,10 +82,10 @@ class samba::server::ads($ensure = present, $changes=$nsswitch ? { true => [ - 'set database[. = 'passwd']/service[1] compat', - 'set database[. = 'passwd']/service[2] winbind', - 'set database[. = 'group']/service[1] compat', - 'set database[. = 'group']/service[2] winbind', + 'set database[. = "passwd"]/service[1] compat', + 'set database[. = "passwd"]/service[2] winbind', + 'set database[. = "group"]/service[1] compat', + 'set database[. = "group"]/service[2] winbind', ], false => [ "rm /files/${nss_file}/database[. = 'passwd']/service[. = 'winbind']", -- cgit v1.2.3 From b4e4a92ff4da6e34a8707ffb49c8ccf6ce316d2b Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Mon, 13 Apr 2015 13:28:45 -0400 Subject: more specs for samba::server use short hand for path to get specs passing --- manifests/server.pp | 6 ++---- spec/classes/samba__server_spec.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 9eace3d..65ea660 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -45,18 +45,16 @@ class samba::server($interfaces = '', 'disable_spoolss': value => $disable_spoolss; } - file {'check_samba_user': + file {'/sbin/check_samba_user': # script checks to see if a samba account exists for a given user - path => '/sbin/check_samba_user', owner => root, group => root, mode => '0755', content => template("${module_name}/check_samba_user"), } - file {'add_samba_user': + file {'/sbin/add_samba_user': # script creates a new samba account for a given user and password - path => '/sbin/add_samba_user', owner => root, group => root, mode => '0755', diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb index 89d994f..fce10bb 100644 --- a/spec/classes/samba__server_spec.rb +++ b/spec/classes/samba__server_spec.rb @@ -6,4 +6,21 @@ describe 'samba::server' do it { should contain_class('samba::server::install') } it { should contain_class('samba::server::config') } it { should contain_class('samba::server::service') } + + it { should contain_samba__server__option('interfaces') } + it { should contain_samba__server__option('bind interfaces only') } + it { should contain_samba__server__option('security') } + it { should contain_samba__server__option('server string') } + it { should contain_samba__server__option('unix password sync') } + it { should contain_samba__server__option('workgroup') } + it { should contain_samba__server__option('socket_options') } + it { should contain_samba__server__option('deadtime') } + it { should contain_samba__server__option('keepalive') } + it { should contain_samba__server__option('load_printers') } + it { should contain_samba__server__option('printing') } + it { should contain_samba__server__option('printcap_name') } + it { should contain_samba__server__option('disable_spoolss') } + + it { should contain_file('/sbin/check_samba_user').with_owner('root') } + it { should contain_file('/sbin/add_samba_user').with_owner('root') } end -- cgit v1.2.3 From e47f9cba618d9b1891836b3d9dfa6d7e09f40e49 Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Mon, 13 Apr 2015 15:14:00 -0400 Subject: document classes to satisfy linting --- manifests/init.pp | 4 +++- manifests/server.pp | 2 ++ manifests/server/ads.pp | 4 +--- manifests/server/config.pp | 2 ++ manifests/server/install.pp | 4 +++- manifests/server/option.pp | 2 ++ manifests/server/service.pp | 2 ++ manifests/server/share.pp | 2 ++ manifests/server/user.pp | 4 +++- manifests/server/winbind.pp | 2 ++ 10 files changed, 22 insertions(+), 6 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/init.pp b/manifests/init.pp index 8a914a4..4fbac9a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,7 +1,9 @@ +# == Class samba +# class samba { include samba::server if samba::server::security == 'ads' { include samba::server::ads } -} \ No newline at end of file +} diff --git a/manifests/server.pp b/manifests/server.pp index 65ea660..d4af927 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -1,3 +1,5 @@ +# == Class samba::server +# class samba::server($interfaces = '', $security = '', $server_string = '', diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp index 781a6a9..1260fd1 100644 --- a/manifests/server/ads.pp +++ b/manifests/server/ads.pp @@ -1,8 +1,6 @@ +# == Class samba::server::ads # This module join samba server to Active Dirctory # -# Copyright (c) 2013 Lebedev Vadim, abraham1901 at g mail dot c o m -# Licensed under the MIT License, http://opensource.org/licenses/MIT - class samba::server::ads($ensure = present, $winbind_acct = 'admin', $winbind_pass = 'SecretPass', diff --git a/manifests/server/config.pp b/manifests/server/config.pp index d51e432..1ecb490 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -1,3 +1,5 @@ +# == Class samba::server::config +# class samba::server::config { file { '/etc/samba': diff --git a/manifests/server/install.pp b/manifests/server/install.pp index 1454bfe..ec98a49 100644 --- a/manifests/server/install.pp +++ b/manifests/server/install.pp @@ -1,5 +1,7 @@ +# == Class samba::server::install +# class samba::server::install { package { 'samba': ensure => installed } -} \ No newline at end of file +} diff --git a/manifests/server/option.pp b/manifests/server/option.pp index 0b34edb..bf491e8 100644 --- a/manifests/server/option.pp +++ b/manifests/server/option.pp @@ -1,3 +1,5 @@ +# == Define samba::server::option +# define samba::server::option ( $value = '' ) { $incl = $samba::server::incl $context = $samba::server::context diff --git a/manifests/server/service.pp b/manifests/server/service.pp index fdd9104..2226497 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -25,6 +25,8 @@ class samba::server::service ($ensure = running, $enable = true) { } default: { fail("${::osfamily} is not supported by this module.") } } +# == Class samba::server::server +# service { $service_name : ensure => $ensure, diff --git a/manifests/server/share.pp b/manifests/server/share.pp index eacd5b7..d86e8c5 100644 --- a/manifests/server/share.pp +++ b/manifests/server/share.pp @@ -1,3 +1,5 @@ +# == Define samba::server::share +# define samba::server::share($ensure = present, $available = '', $browsable = '', diff --git a/manifests/server/user.pp b/manifests/server/user.pp index e3d84cc..b8f2e61 100644 --- a/manifests/server/user.pp +++ b/manifests/server/user.pp @@ -1,4 +1,6 @@ -define samba::server::user( +# == Class samba::server::user +# +define samba::server::user ( $password, $user_name = $name, ) { diff --git a/manifests/server/winbind.pp b/manifests/server/winbind.pp index 76136b9..68128e5 100644 --- a/manifests/server/winbind.pp +++ b/manifests/server/winbind.pp @@ -1,3 +1,5 @@ +# == Class samba::server::winbind +# class samba::server::winbind ($ensure = running, $enable = true) { $service_name = 'winbind' -- cgit v1.2.3 From 68ada05411e87629b0f0b435ca35e5f1e44353e3 Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Tue, 14 Jul 2015 11:42:25 +0200 Subject: Add kernel oplocks and pam password change options --- manifests/server.pp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index d4af927..2b261f9 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -12,6 +12,8 @@ class samba::server($interfaces = '', $printing = '', $printcap_name = '', $disable_spoolss = '', + $kernel_oplocks = '', + $pam_password_change = '', $bind_interfaces_only = 'yes',) { include samba::server::install @@ -45,6 +47,8 @@ class samba::server($interfaces = '', 'printing': value => $printing; 'printcap_name': value => $printcap_name; 'disable_spoolss': value => $disable_spoolss; + 'kernel oplocks': value => $kernel_oplocks; + 'pam password change': value => $pam_password_change, } file {'/sbin/check_samba_user': -- cgit v1.2.3 From 647254932e323869e972310fcbb1c1ecda6d4d3e Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Wed, 22 Jul 2015 10:53:52 +0200 Subject: Add 'os level' and 'preferred master' global options --- manifests/server.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 2b261f9..1c58f28 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -14,6 +14,8 @@ class samba::server($interfaces = '', $disable_spoolss = '', $kernel_oplocks = '', $pam_password_change = '', + $os_level = '', + $preferred_master = '', $bind_interfaces_only = 'yes',) { include samba::server::install @@ -48,7 +50,9 @@ class samba::server($interfaces = '', 'printcap_name': value => $printcap_name; 'disable_spoolss': value => $disable_spoolss; 'kernel oplocks': value => $kernel_oplocks; - 'pam password change': value => $pam_password_change, + 'pam password change': value => $pam_password_change; + 'os level': value => $os_level; + 'preferred master': value => $preferred_master; } file {'/sbin/check_samba_user': -- cgit v1.2.3 From 5c4eed67cf85f2ee4a652d21f649228d80f7c262 Mon Sep 17 00:00:00 2001 From: Jan Kanis Date: Thu, 30 Jul 2015 12:41:20 +0200 Subject: Add 'netbios name' option --- manifests/server.pp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 1c58f28..641384f 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -4,6 +4,7 @@ class samba::server($interfaces = '', $security = '', $server_string = '', $unix_password_sync = '', + $netbios_name = '', $workgroup = '', $socket_options = '', $deadtime = '', @@ -41,6 +42,7 @@ class samba::server($interfaces = '', 'security': value => $security; 'server string': value => $server_string; 'unix password sync': value => $unix_password_sync; + 'netbios name': value => $netbios_name; 'workgroup': value => $workgroup; 'socket_options': value => $socket_options; 'deadtime': value => $deadtime; -- cgit v1.2.3 From 6352e26538d0fe33badce2eb54c9f0ba66af310f Mon Sep 17 00:00:00 2001 From: Iban Nieto Date: Tue, 6 Oct 2015 11:24:30 +0200 Subject: Add 'map to guest' global option --- README.md | 3 +++ manifests/server.pp | 2 ++ 2 files changed, 5 insertions(+) (limited to 'manifests/server.pp') diff --git a/README.md b/README.md index a0595f7..468a783 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,9 @@ Most configuration options are optional. 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request +## Module modified +Added "map to guest" in samba::server + ## License This module is released under the MIT license: diff --git a/manifests/server.pp b/manifests/server.pp index 641384f..4120154 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -12,6 +12,7 @@ class samba::server($interfaces = '', $load_printers = '', $printing = '', $printcap_name = '', + $map_to_guest = '', $disable_spoolss = '', $kernel_oplocks = '', $pam_password_change = '', @@ -50,6 +51,7 @@ class samba::server($interfaces = '', 'load_printers': value => $load_printers; 'printing': value => $printing; 'printcap_name': value => $printcap_name; + 'map to guest': value => $map_to_guest; 'disable_spoolss': value => $disable_spoolss; 'kernel oplocks': value => $kernel_oplocks; 'pam password change': value => $pam_password_change; -- cgit v1.2.3 From b2d5840ca565eb79672b152bcd74a24127929808 Mon Sep 17 00:00:00 2001 From: David Sheldon Date: Fri, 9 Oct 2015 17:31:30 +0100 Subject: Fix "load printers" setting name Samba doesn't seem to understand "load_printers", it's "load printers" instead. Ignoring unknown parameter "load_printers" --- manifests/server.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 4120154..b4e9955 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -48,7 +48,7 @@ class samba::server($interfaces = '', 'socket_options': value => $socket_options; 'deadtime': value => $deadtime; 'keepalive': value => $keepalive; - 'load_printers': value => $load_printers; + 'load printers': value => $load_printers; 'printing': value => $printing; 'printcap_name': value => $printcap_name; 'map to guest': value => $map_to_guest; -- cgit v1.2.3 From 47c02047d9924bf2a62d8f099e28e6366b60b5fb Mon Sep 17 00:00:00 2001 From: David Sheldon Date: Fri, 9 Oct 2015 18:25:29 +0100 Subject: Fix the rest of the options with _ in Having read man smb.conf, none of these options should have _ in the resulting option name. --- manifests/server.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index b4e9955..a73ad99 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -45,14 +45,14 @@ class samba::server($interfaces = '', 'unix password sync': value => $unix_password_sync; 'netbios name': value => $netbios_name; 'workgroup': value => $workgroup; - 'socket_options': value => $socket_options; + 'socket options': value => $socket_options; 'deadtime': value => $deadtime; 'keepalive': value => $keepalive; 'load printers': value => $load_printers; 'printing': value => $printing; - 'printcap_name': value => $printcap_name; + 'printcap name': value => $printcap_name; 'map to guest': value => $map_to_guest; - 'disable_spoolss': value => $disable_spoolss; + 'disable spoolss': value => $disable_spoolss; 'kernel oplocks': value => $kernel_oplocks; 'pam password change': value => $pam_password_change; 'os level': value => $os_level; -- cgit v1.2.3 From 95cb988077ec2f5c79e4a2bd67d4b252fdc8739c Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Mon, 7 Dec 2015 16:17:25 -0500 Subject: clean whitespace --- manifests/server.pp | 1 - spec/fixtures/manifests/init.pp | 2 -- 2 files changed, 3 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index a73ad99..550659c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -74,5 +74,4 @@ class samba::server($interfaces = '', mode => '0755', content => template("${module_name}/add_samba_user"), } - } diff --git a/spec/fixtures/manifests/init.pp b/spec/fixtures/manifests/init.pp index 0f64360..94005cd 100644 --- a/spec/fixtures/manifests/init.pp +++ b/spec/fixtures/manifests/init.pp @@ -1,7 +1,5 @@ node 'testhost.example.com' { - include samba::server - } node default {} -- cgit v1.2.3 From 9d63c7be3fa57e4af93c787f8b740658ec14f1f6 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Fri, 22 Jan 2016 15:32:28 +0000 Subject: Remove check_samba_user and add_samba_user scripts Call the pdbedit commands directly from samba::server::user instead --- manifests/server.pp | 16 ---------------- manifests/server/user.pp | 8 +++++--- spec/classes/samba__server_spec.rb | 3 --- spec/defines/samba__server__user_spec.rb | 14 ++++++++++++++ templates/add_samba_user | 16 ---------------- templates/check_samba_user | 16 ---------------- 6 files changed, 19 insertions(+), 54 deletions(-) create mode 100644 spec/defines/samba__server__user_spec.rb delete mode 100644 templates/add_samba_user delete mode 100644 templates/check_samba_user (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 550659c..8a5853c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -58,20 +58,4 @@ class samba::server($interfaces = '', 'os level': value => $os_level; 'preferred master': value => $preferred_master; } - - file {'/sbin/check_samba_user': - # script checks to see if a samba account exists for a given user - owner => root, - group => root, - mode => '0755', - content => template("${module_name}/check_samba_user"), - } - - file {'/sbin/add_samba_user': - # script creates a new samba account for a given user and password - owner => root, - group => root, - mode => '0755', - content => template("${module_name}/add_samba_user"), - } } diff --git a/manifests/server/user.pp b/manifests/server/user.pp index b8f2e61..d10a602 100644 --- a/manifests/server/user.pp +++ b/manifests/server/user.pp @@ -4,10 +4,12 @@ define samba::server::user ( $password, $user_name = $name, ) { + require ::samba::server::install + exec { "add smb account for ${user_name}": - command => "/sbin/add_samba_user '${user_name}' '${password}'" , - unless => "/sbin/check_samba_user '${user_name}'" , + command => "/bin/echo -e '${password}\\n${password}\\n' | /usr/bin/pdbedit --password-from-stdin -a '${user_name}'", + unless => "/usr/bin/pdbedit '${user_name}'", require => [ User[$user_name] ], - notify => Class['samba::server::service'] + notify => Class['samba::server::service'] #TODO: Is this really required?? } } diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb index 69fa0ec..dbf840a 100644 --- a/spec/classes/samba__server_spec.rb +++ b/spec/classes/samba__server_spec.rb @@ -20,7 +20,4 @@ describe 'samba::server' do it { should contain_samba__server__option('printing') } it { should contain_samba__server__option('printcap name') } it { should contain_samba__server__option('disable spoolss') } - - it { should contain_file('/sbin/check_samba_user').with_owner('root') } - it { should contain_file('/sbin/add_samba_user').with_owner('root') } end diff --git a/spec/defines/samba__server__user_spec.rb b/spec/defines/samba__server__user_spec.rb new file mode 100644 index 0000000..c7ae00c --- /dev/null +++ b/spec/defines/samba__server__user_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'samba::server::user', :type => :define do + let(:title) { 'test_user' } + let(:params) {{ :password => 'secret' }} + + it { is_expected.to contain_samba__server__user('test_user') } + it { is_expected.to contain_exec('add smb account for test_user').with( + :command => '/bin/echo -e \'secret\nsecret\n\' | /usr/bin/pdbedit --password-from-stdin -a \'test_user\'', + :unless => '/usr/bin/pdbedit \'test_user\'', + :require => 'User[test_user]', + :notify => 'Class[Samba::Server::Service]' + ) } +end diff --git a/templates/add_samba_user b/templates/add_samba_user deleted file mode 100644 index cc1d56b..0000000 --- a/templates/add_samba_user +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# This script adds a samba account for a given user and password -# call as: -# > add_samba_user "USERNAME" "PASSWORD" - -/bin/echo -e "$2\n$2\n" | sudo /usr/bin/pdbedit -a "$1" -t 1>/dev/null -results=$? - -if [ $results = 0 ]; then - echo "added samba account for '$1'" -else - echo "could not add samba account for '$1'" -fi - -exit $results diff --git a/templates/check_samba_user b/templates/check_samba_user deleted file mode 100644 index 431c3c4..0000000 --- a/templates/check_samba_user +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# This script checks to see if a given user account exists on samba -# if so, it returns 0 -# otherwise it returns 1 - -sudo /usr/bin/pdbedit -L | egrep -q "^$1:" -exists=$? - -if [ $exists = 0 ]; then - echo "'$1' is a samba user" -else - echo "no samba account matching '$1'" -fi - -exit $exists -- cgit v1.2.3 From 9c84eb144deeeb67001e9cc95101f48d77e43501 Mon Sep 17 00:00:00 2001 From: Christian Döring Date: Tue, 2 Feb 2016 17:45:52 +0100 Subject: Enable global guest-account setting --- manifests/server.pp | 4 +++- manifests/server/share.pp | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 8a5853c..027471c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -12,7 +12,8 @@ class samba::server($interfaces = '', $load_printers = '', $printing = '', $printcap_name = '', - $map_to_guest = '', + $map_to_guest = 'Never', + $guest_account = '', $disable_spoolss = '', $kernel_oplocks = '', $pam_password_change = '', @@ -52,6 +53,7 @@ class samba::server($interfaces = '', 'printing': value => $printing; 'printcap name': value => $printcap_name; 'map to guest': value => $map_to_guest; + 'guest account': value => $guest_account; 'disable spoolss': value => $disable_spoolss; 'kernel oplocks': value => $kernel_oplocks; 'pam password change': value => $pam_password_change; diff --git a/manifests/server/share.pp b/manifests/server/share.pp index c682055..e5e23f1 100644 --- a/manifests/server/share.pp +++ b/manifests/server/share.pp @@ -11,7 +11,6 @@ define samba::server::share($ensure = present, $force_directory_mask = '', $force_group = '', $force_user = '', - $guest_account = '', $guest_ok = '', $guest_only = '', $hide_unreadable = '', @@ -94,10 +93,6 @@ define samba::server::share($ensure = present, '' => "rm \"${target}/force user\"", default => "set \"${target}/force user\" '${force_user}'", }, - $guest_account ? { - '' => "rm \"${target}/guest account\"", - default => "set \"${target}/guest account\" '${guest_account}'", - }, $guest_ok ? { true => "set \"${target}/guest ok\" yes", false => "set \"${target}/guest ok\" no", -- cgit v1.2.3 From 430054887e7894690524bcd7d4a629280f18479f Mon Sep 17 00:00:00 2001 From: Christian Döring Date: Fri, 5 Feb 2016 17:23:32 +0100 Subject: Convert tabs to spaces to comply style-guide --- manifests/server.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 027471c..8d6a214 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -13,7 +13,7 @@ class samba::server($interfaces = '', $printing = '', $printcap_name = '', $map_to_guest = 'Never', - $guest_account = '', + $guest_account = '', $disable_spoolss = '', $kernel_oplocks = '', $pam_password_change = '', @@ -53,7 +53,7 @@ class samba::server($interfaces = '', 'printing': value => $printing; 'printcap name': value => $printcap_name; 'map to guest': value => $map_to_guest; - 'guest account': value => $guest_account; + 'guest account': value => $guest_account; 'disable spoolss': value => $disable_spoolss; 'kernel oplocks': value => $kernel_oplocks; 'pam password change': value => $pam_password_change; -- cgit v1.2.3 From d8c319fb569977afcd54f72ddfe3c6aa2b61a9f1 Mon Sep 17 00:00:00 2001 From: Jirgn Mssnr Date: Tue, 9 Feb 2016 17:51:12 +0100 Subject: added share config via hiera --- manifests/server.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 8d6a214..59d5d51 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -19,7 +19,8 @@ class samba::server($interfaces = '', $pam_password_change = '', $os_level = '', $preferred_master = '', - $bind_interfaces_only = 'yes',) { + $bind_interfaces_only = 'yes', + $shares = {},) { include samba::server::install include samba::server::config @@ -60,4 +61,6 @@ class samba::server($interfaces = '', 'os level': value => $os_level; 'preferred master': value => $preferred_master; } + + create_resources(samba::server::share, $shares) } -- cgit v1.2.3 From 0385193ee30c830e81be53b1d7484ae27cdd2b85 Mon Sep 17 00:00:00 2001 From: Jirgn Mssnr Date: Mon, 22 Feb 2016 13:47:19 +0100 Subject: added param users for use in hiera added tests for samba::server::users --- manifests/server.pp | 4 +++- spec/classes/samba__server_spec.rb | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'manifests/server.pp') diff --git a/manifests/server.pp b/manifests/server.pp index 59d5d51..cbc61a9 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -20,7 +20,8 @@ class samba::server($interfaces = '', $os_level = '', $preferred_master = '', $bind_interfaces_only = 'yes', - $shares = {},) { + $shares = {}, + $users = {}, ) { include samba::server::install include samba::server::config @@ -63,4 +64,5 @@ class samba::server($interfaces = '', } create_resources(samba::server::share, $shares) + create_resources(samba::server::user, $users) } diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb index d19fe6a..46c5b15 100644 --- a/spec/classes/samba__server_spec.rb +++ b/spec/classes/samba__server_spec.rb @@ -36,8 +36,31 @@ describe 'samba::server' do } } }} - it { should contain_samba__server__share( 'testShare' ) } - it { should contain_samba__server__share( 'testShare2' ) } + it { + should contain_samba__server__share( 'testShare' ).with({ + 'path' => '/path/to/some/share', + 'browsable' => true, + 'writable' => true, + 'guest_ok' => true, + 'guest_only' => true, + }) + } + it { should contain_samba__server__share( 'testShare2' ).with_path('/some/other/path') } + end + + context 'with hiera users hash' do + let(:params) {{ + 'users' => { + 'testUser' => { + 'password' => 'testpass01' + }, + 'testUser2' => { + 'password' => 'testpass02' + } + } + }} + it { should contain_samba__server__user( 'testUser' ).with_password('testpass01') } + it { should contain_samba__server__user( 'testUser2' ).with_password('testpass02') } end end -- cgit v1.2.3