Defined Type: systemd::unit::automount
- Defined in:
- manifests/unit/automount.pp
Overview
This function manages an automount systemd unit. An automount unit must always be accompanyied by a mount unit that will be automatically activated when the automount path is accessed. See systemd.automount(5) for details.
By default, both the mount and automount systemd unit are configured here.
Parameters:
description - what this is all about
what - what to mount (e.g. device path or remote path)
where - where to mount (e.g. local mount point)
type - type of mount (e.g. XFS, NFS, BIND, LOOP, ..)
options - mount options (e.g. async, ro, nodev, ..)
idle_timout - timespan until automatic unmount when idle
directory_mode - access mode for auto-created mountpoint path components
manage_mount - whether to manage the accompanying mount unit
*_options - other systemd directives (see systemd::unit)
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'manifests/unit/automount.pp', line 23
define systemd::unit::automount (
String $description,
String $what,
String $where,
String $ensure = 'present',
Optional[String] $type = undef,
Optional[String] $options = undef,
Optional[String] $idle_timeout = undef,
Optional[String] $directory_mode = '0755',
Boolean $manage_mount_unit = true,
Optional[Variant[[Array[String],String]]] $wantedby = ['multi-user.target'],
Hash $unit_options = {},
Hash $install_options = {},
Hash $mount_options = {},
Hash $automount_options = {},
Boolean $manage_unitstatus = true,
Enum['running','stopped'] $unit_ensure = 'running',
Boolean $unit_enable = true,
) {
include ::systemd
#
## mount and automount units place restictions on the unit name:
## it must be the mount path with slashes replaced by dashes, except
## for the first slash, which must be removed.
#
$unit_name = systemd::str2unitname($where)
## Configure the automount unit
systemd::unit { "${title}::automount":
ensure => $ensure,
unit_name => $unit_name,
unit_type => 'automount',
manage_unitstatus => $manage_unitstatus,
unit_ensure => $unit_ensure,
unit_enable => $unit_enable,
unit_options => $unit_options + { 'Description' => $description, },
install_options => $install_options + { 'WantedBy' => $wantedby, },
type_options => $automount_options + {
'Where' => $where,
'DirectoryMode' => $directory_mode,
'TimeoutIdleSec' => $idle_timeout
},
}
## XXX - automount units should auto-create mountpoints
## but see radhat bug 1585411 for why we must do it ourselves for now..
if $ensure == 'present' {
exec { "${title}::mkwhere" :
command => "/bin/mkdir -p '${where}'",
umask => String(0777 - Integer($directory_mode), '%#o'),
creates => $where,
before => Systemd::Unit["${title}::automount"]
}
}
unless $manage_mount_unit { return() }
#
## Configure the accompanying mount unit
##
## For the automount/mount combo to work as expected, the mount
## unit should remain disabled and stopped. It will be started and
## stopped only on demand by events on the automount unit.
#
systemd::unit { "${title}::mount":
ensure => $ensure,
unit_name => $unit_name,
unit_type => 'mount',
manage_unitstatus => false,
unit_options => { 'Description' => $description, },
install_options => {},
type_options => {
'What' => $what,
'Where' => $where,
'Type' => $type,
'Options' => $options
},
}
}
|