-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
mapfile.pp
60 lines (57 loc) · 1.81 KB
/
mapfile.pp
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
# Define autofs::mapfile
#
# Defined type to manage overall autofs map files
#
# @see https://voxpupuli.org/puppet-autofs Home
# @see https://voxpupuli.org/puppet-autofs/puppet_classes/autofs.html puppet_classes::autofs
# @see https://www.github.com/voxpupuli/puppet-autofs Github
# @see https://forge.puppet.com/puppet/autofs Puppet Forge
#
# @author Vox Pupuli <voxpupuli@groups.io>
# @author David Hollinger III <david.hollinger@moduletux.com>
#
# @param ensure Whether the mapfile should be present on the target system
# @param path An absolute path to the map file
# @param mappings an array of mappings to enroll in the file. Additional
# mappings can be specified for this mapfile via autofs::mapping resources
# @param replace Whether to replace the contents of any an existing file
# at the specified path
#
define autofs::mapfile (
Enum['present', 'absent'] $ensure = 'present',
Stdlib::Absolutepath $path = $title,
Array[Autofs::Fs_mapping] $mappings = [],
Boolean $replace = true,
) {
include '::autofs'
unless $::autofs::package_ensure == 'absent' {
if $autofs::reload_command {
Concat {
before => Service[$autofs::service_name],
notify => Exec['automount-reload'],
}
} else {
Concat {
notify => Service[$autofs::service_name],
}
}
}
concat { $path:
ensure => $ensure,
owner => $autofs::map_file_owner,
group => $autofs::map_file_group,
mode => '0644',
replace => $replace,
require => Class['autofs::package'],
warn => template('autofs/mapfile.banner.erb'),
}
if $ensure == 'present' {
$mappings.each |$mapping| {
autofs::mapping { "${path}:${mapping[key]}":
ensure => 'present',
mapfile => $path,
* => $mapping,
}
}
}
}