aboutsummaryrefslogtreecommitdiff
path: root/manifests/server.pp
blob: 9b6d3c0df7649d981a8649895c2877c1bbc3786c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class samba::server($interfaces = '',
                    $security = '',
                    $server_string = '',
                    $unix_password_sync = '',
                    $workgroup = '') {

  include samba::server::install
  include samba::server::config
  include samba::server::service

  $context = '/files/etc/samba/smb.conf'
  $target = "target[. = 'global']"

  augeas { 'global-section':
    context => $context,
    changes => "set ${target} global",
    require => Class['samba::server::config'],
    notify  => Class['samba::server::service']
  }


  set_samba_option {
    'bind interfaces only': value => 'yes';
    'security':             value => $security;
    'server string':        value => $server_string;
    'unix password sync':   value => $unix_password_sync;
    'workgroup':            value => $workgroup;
  }
}

define set_samba_option ( $value = '', $signal = 'samba::server::service' ) {
  $context = $samba::server::context
  $target = $samba::server::target
  $changes = $value ? {
    default => "set \"${target}/$name\" $value",
    ''      => "rm ${target}/$name",
  }
  augeas { "samba-$name":
    context => $context,
    changes => $changes,
    require => Augeas['global-section'],
    notify  => Class[$signal]
  }
}