define systemd_mount ( String $what, # elrond:/files String $where = $name, # /usr/net Boolean $automount = false, String $wantedBy = 'default.target', Array[String] $options = [], ) { $mostly_fixed = $where.map |$c| { $c ? { '/' => '-', '-' => '\\x2d', default => $c, } }.join('') $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, options => $options, 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, } } }