aboutsummaryrefslogtreecommitdiff
path: root/manifests/server.pp
blob: cc1a95110122694da21b1069720c6b016945c03b (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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']
  }

  augeas { 'global-interfaces':
    context => $context,
    changes => $interfaces ? {
      default => ["set \"${target}/interfaces\" '${interfaces}'", "set \"${target}/bind interfaces only\" yes"],
      ''      => ["rm \"${target}/interfaces\"", "rm \"${target}/bind interfaces only\""],
    },
    require => Augeas['global-section'],
    notify  => Class['samba::server::service']
  }

  augeas { 'global-security':
    context => $context,
    changes => $security ? {
      default => "set \"${target}/security\" '${security}'",
      ''      => "rm \"${target}/security\"",
    },
    require => Augeas['global-section'],
    notify  => Class['samba::server::service']
  }

  augeas { 'global-server_string':
    context => $context,
    changes => $server_string ? {
      default => "set \"${target}/server string\" '${server_string}'",
      ''      => "rm \"${target}/server string\"",
    },
    require => Augeas['global-section'],
    notify  => Class['samba::server::service']
  }

  augeas { 'global-unix_password_sync':
    context => $context,
    changes => $unix_password_sync ? {
      default => "set \"${target}/unix password sync\" '$unix_password_sync'",
      '' => "rm \"${target}/unix_password_sync\"",
    },
    require => Augeas['global-section'],
    notify => Class['samba::server::service']
  }

  augeas { 'global-workgroup':
    context => $context,
    changes => $workgroup ? {
      default => "set ${target}/workgroup '${workgroup}'",
      ''      => "rm ${target}/workgroup",
    },
    require => Augeas['global-section'],
    notify  => Class['samba::server::service']
  }
}