aboutsummaryrefslogtreecommitdiff
path: root/manifests/server/share.pp
blob: a40ed46826818a270e192e3e2263086b9cc2d7c2 (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
71
72
define samba::server::share($ensure = present,
                    $description = '',
                    $path = '',
                    $browsable = '',
                    $guest_ok = '',
                    $read_only = '') {

  $context = "/files/etc/samba/smb.conf"
  $target = "target[. = '${name}']"

  augeas { "${name}-section":
    context => $context,
    changes => $ensure ? {
      present => "set ${target} ${name}",
      default => "rm ${target} ${name}",
    },
    require => Class["samba::server::config"],
    notify => Class["samba::server::service"]
  }

  if $ensure == "present" {
    augeas { "${name}-comment":
      context => $context,
      changes => $description ? {
        default => "set ${target}/comment ${description}",
        '' => "rm ${target}/comment",
      },
      require => Augeas["${name}-section"],
      notify => Class["samba::server::service"]
    }

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

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

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

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