summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 7938555abbbbc3cff72d4e11f690f52766c91d95 (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
define systemd_mount (
  String $what,  # elrond:/files
  String $where = $name, # /usr/net
  Boolean $automount = false,
  String $wantedBy = 'default.target',
) {

  $mostly_fixed = regsubst($where, '/', '-', 'G')
  $fixed = if $mostly_fixed[0] == '-' {
    $mostly_fixed[1, -1] # drop first char
  } else {
    $mostly_fixed
  }

  systemd::unit_file { "${fixed}.mount":
      content => epp('systemd_mount/mount.epp', {
        what     => $what,
        where    => $where,
        wantedby => if ($automount) { '' } else { "WantedBy=${wantedBy}" },
      }),
  }

  if ($automount) {
    systemd::unit_file { "${fixed}.automount":
      content => epp('systemd_mount/automount.epp', {
        where    => $where,
        wantedBy => "WantedBy=${wantedBy}",
        }),
    }

    service { "${fixed}.automount":
      enable => true,
      ensure => running,
    }
  } else {
    service { "${fixed}.mount":
      enable => true,
      ensure => running,
    }
  }

}