Skip to content

Commit 0c09413

Browse files
author
Alexis Autret
committed
Add some params:
server params : - dns proxy - log file - max log size - obey pam restrictions - panic action - passdb backend - passwd chat - passwd program - server role - syslog - usershare allow guests share params : - hosts allow - acl allow execute always Add a test on ubuntu 16.04
1 parent 1020f7c commit 0c09413

File tree

7 files changed

+152
-56
lines changed

7 files changed

+152
-56
lines changed

README.md

+35-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Module for provisioning Samba
66

77
Supports:
88

9-
* Ubuntu: 14.04, 12.04
9+
* Ubuntu: 14.04, 12.04, 16.04 LTS
1010
* Debian: 8.x, 7.x
1111
* CentOS: 7.x, 6.x
1212

@@ -29,26 +29,43 @@ Tweak and add the following to your site manifest:
2929
```puppet
3030
node 'server.example.com' {
3131
class {'samba::server':
32-
workgroup => 'example',
33-
server_string => "Example Samba Server",
34-
interfaces => "eth0 lo",
35-
security => 'share'
32+
workgroup => 'WORKGROUP',
33+
server_string => "${::hostname}",
34+
dns_proxy => 'no',
35+
log_file => '/var/log/samba/log.%m',
36+
max_log_size => '1000',
37+
syslog => '0',
38+
panic_action => '/usr/share/samba/panic-action %d',
39+
server_role => 'standalone server',
40+
passdb_backend => 'tdbsam',
41+
obey_pam_restrictions => 'yes',
42+
unix_password_sync => 'yes',
43+
passwd_program => '/usr/bin/passwd %u',
44+
passwd_chat => '*Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .',
45+
pam_password_change => 'yes',
46+
map_to_guest => 'Never',
47+
usershare_allow_guests => 'yes',
48+
#interfaces => "eth0 lo",
49+
bind_interfaces_only => 'no',
50+
security => 'user',
3651
}
3752
3853
samba::server::share {'example-share':
39-
comment => 'Example Share',
40-
path => '/path/to/share',
41-
guest_only => true,
42-
guest_ok => true,
43-
guest_account => "guest",
44-
browsable => false,
45-
create_mask => 0777,
46-
force_create_mask => 0777,
47-
directory_mask => 0777,
48-
force_directory_mask => 0777,
49-
force_group => 'group',
50-
force_user => 'user',
51-
copy => 'some-other-share',
54+
comment => 'Example Share',
55+
path => '/path/to/share',
56+
guest_only => true,
57+
guest_ok => true,
58+
guest_account => "guest",
59+
browsable => false,
60+
create_mask => 0777,
61+
force_create_mask => 0777,
62+
directory_mask => 0777,
63+
force_directory_mask => 0777,
64+
force_group => 'group',
65+
force_user => 'user',
66+
copy => 'some-other-share',
67+
hosts_allow => '127.0.0.1, 192.168.0.1'
68+
acl_allow_execute_always => true,
5269
}
5370
}
5471
```

manifests/server.pp

+58-36
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
# == Class samba::server
22
#
3-
class samba::server($interfaces = '',
4-
$security = '',
5-
$server_string = '',
6-
$unix_password_sync = '',
7-
$netbios_name = '',
8-
$workgroup = '',
9-
$socket_options = '',
3+
class samba::server($bind_interfaces_only = 'yes',
104
$deadtime = '',
11-
$keepalive = '',
12-
$load_printers = '',
13-
$printing = '',
14-
$printcap_name = '',
15-
$map_to_guest = 'Never',
16-
$guest_account = '',
175
$disable_spoolss = '',
6+
$dns_proxy = '',
7+
$guest_account = '',
8+
$keepalive = '',
189
$kernel_oplocks = '',
19-
$pam_password_change = '',
10+
$load_printers = '',
11+
$log_file = '',
12+
$map_to_guest = '',
13+
$max_log_size = '',
14+
$netbios_name = '',
15+
$obey_pam_restrictions = '',
2016
$os_level = '',
17+
$pam_password_change = '',
18+
$panic_action = '',
19+
$passdb_backend = '',
20+
$passwd_chat = '*Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .',
21+
$passwd_program = '',
2122
$preferred_master = '',
22-
$bind_interfaces_only = 'yes',
23+
$printcap_name = '',
24+
$printing = '',
25+
$security = '',
26+
$server_role = '',
27+
$server_string = '',
2328
$shares = {},
24-
$users = {}, ) {
29+
$socket_options = '',
30+
$syslog = '',
31+
$unix_password_sync = '',
32+
$usershare_allow_guests = '',
33+
$users = {},
34+
$workgroup = '',
35+
$interfaces = '' ) {
2536

2637
include samba::server::install
2738
include samba::server::config
@@ -41,26 +52,37 @@
4152
}
4253

4354
samba::server::option {
44-
'interfaces': value => $interfaces;
45-
'bind interfaces only': value => $bind_interfaces_only;
46-
'security': value => $security;
47-
'server string': value => $server_string;
48-
'unix password sync': value => $unix_password_sync;
49-
'netbios name': value => $netbios_name;
50-
'workgroup': value => $workgroup;
51-
'socket options': value => $socket_options;
52-
'deadtime': value => $deadtime;
53-
'keepalive': value => $keepalive;
54-
'load printers': value => $load_printers;
55-
'printing': value => $printing;
56-
'printcap name': value => $printcap_name;
57-
'map to guest': value => $map_to_guest;
58-
'guest account': value => $guest_account;
59-
'disable spoolss': value => $disable_spoolss;
60-
'kernel oplocks': value => $kernel_oplocks;
61-
'pam password change': value => $pam_password_change;
62-
'os level': value => $os_level;
63-
'preferred master': value => $preferred_master;
55+
'bind interfaces only': value => $bind_interfaces_only;
56+
'deadtime': value => $deadtime;
57+
'disable spoolss': value => $disable_spoolss;
58+
'dns proxy': value => $dns_proxy;
59+
'guest account': value => $guest_account;
60+
'keepalive': value => $keepalive;
61+
'kernel oplocks': value => $kernel_oplocks;
62+
'load printers': value => $load_printers;
63+
'log file': value => $log_file;
64+
'map to guest': value => $map_to_guest;
65+
'max log size': value => $max_log_size;
66+
'netbios name': value => $netbios_name;
67+
'obey pam restrictions': value => $obey_pam_restrictions;
68+
'os level': value => $os_level;
69+
'pam password change': value => $pam_password_change;
70+
'panic action': value => $panic_action;
71+
'passdb backend': value => $passdb_backend;
72+
'passwd chat': value => $passwd_chat;
73+
'passwd program': value => $passwd_program;
74+
'preferred master': value => $preferred_master;
75+
'printcap name': value => $printcap_name;
76+
'printing': value => $printing;
77+
'security': value => $security;
78+
'server role': value => $server_role;
79+
'server string': value => $server_string;
80+
'socket options': value => $socket_options;
81+
'syslog': value => $syslog;
82+
'unix password sync': value => $unix_password_sync;
83+
'usershare allow guests': value => $usershare_allow_guests;
84+
'workgroup': value => $workgroup;
85+
'interfaces': value => $interfaces;
6486
}
6587

6688
create_resources(samba::server::share, $shares)

manifests/server/share.pp

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
$printer_name = '',
4141
$msdfs_root = '',
4242
$guest_account = '',
43+
$hosts_allow = '',
44+
$acl_allow_execute_always = '',
4345
) {
4446

4547
$incl = $samba::server::incl
@@ -239,6 +241,15 @@
239241
'' => "rm \"${target}/guest account\"",
240242
default => "set \"${target}/guest account\" '${guest_account}'",
241243
},
244+
$hosts_allow ? {
245+
'' => "rm \"${target}/hosts allow\"",
246+
default => "set \"${target}/hosts allow\" '${hosts_allow}'",
247+
},
248+
$acl_allow_execute_always ? {
249+
true => "set \"${target}/acl allow execute always\" yes",
250+
false => "set \"${target}/acl allow execute always\" no",
251+
default => "rm \"${target}/acl allow execute always\"",
252+
},
242253
]
243254

244255
augeas { "${name}-changes":

spec/acceptance/basic_samba_spec.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
let(:pp) {"
66
class { 'samba::server':
77
workgroup => 'example',
8-
server_string => 'Example Samba Server'
8+
server_string => 'Example Samba Server',
9+
dns_proxy => 'no',
10+
server_role => 'standalone server',
911
}
1012
1113
samba::server::share {'example-share':
@@ -23,6 +25,7 @@ class { 'samba::server':
2325
force_user => 'user',
2426
hide_dot_files => false,
2527
msdfs_root => true,
28+
hosts_allow => '127.0.0.1'
2629
}
2730
"}
2831

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HOSTS:
2+
ubuntu-server-1604-x64:
3+
roles:
4+
- master
5+
platform: ubuntu-1604-amd64
6+
box: puppetlabs/ubuntu-16.04-64-nocm
7+
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-16.04-64-nocm
8+
hypervisor: vagrant
9+
CONFIG:
10+
log_level: verbose
11+
type: foss
12+
color: false

spec/classes/samba__server_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
it { should contain_samba__server__option('printing') }
2121
it { should contain_samba__server__option('printcap name') }
2222
it { should contain_samba__server__option('disable spoolss') }
23+
it { should contain_samba__server__option('dns proxy') }
24+
it { should contain_samba__server__option('log file') }
25+
it { should contain_samba__server__option('max log size') }
26+
it { should contain_samba__server__option('obey pam restrictions') }
27+
it { should contain_samba__server__option('panic action') }
28+
it { should contain_samba__server__option('passdb backend') }
29+
it { should contain_samba__server__option('passwd chat') }
30+
it { should contain_samba__server__option('passwd program') }
31+
it { should contain_samba__server__option('server role') }
32+
it { should contain_samba__server__option('syslog') }
33+
it { should contain_samba__server__option('usershare allow guests') }
2334

2435
context 'with hiera shares hash' do
2536
let(:params) {{

spec/defines/samba__server__share_spec.rb

+21-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
set.with("printer name")
4545
set.with("msdfs root")
4646
set.with("guest account")
47+
set.with("hosts allow")
48+
set.with("acl allow execute always")
4749
end
4850
let(:change_set) { default_changes }
4951
let(:changes) { change_set.to_a }
@@ -75,7 +77,7 @@
7577
{
7678
"operatingsystem" => "Ubuntu",
7779
"operatingsystemrelease" => [
78-
"14.04"
80+
"16.04"
7981
]
8082
},
8183
{
@@ -682,6 +684,24 @@
682684
}}
683685
let(:change_set) { default_changes.with("guest account", "'someone'") }
684686
end
687+
688+
context 'with hosts_allow set to "127.0.0.1"' do
689+
include_examples "default share"
690+
let(:params) {{
691+
:ensure => 'present',
692+
:hosts_allow => '127.0.0.1',
693+
}}
694+
let(:change_set) { default_changes.with("hosts allow", "127.0.0.1") }
695+
end
696+
697+
context 'with acl_allow_execute_always to "true"' do
698+
include_examples "default share"
699+
let(:params) {{
700+
:ensure => 'present',
701+
:acl_allow_execute_always => true,
702+
}}
703+
let(:change_set) { default_changes.with("acl allow execute always", "true") }
704+
end
685705
end
686706
end
687707
end

0 commit comments

Comments
 (0)