Defined Type: autofs::mount
- Defined in:
- manifests/mount.pp
Summary
Defined type to manage mount point definitions in the Autofs master map.Overview
autofs::mount { ‘home’:
mount => '/home',
mapfile => '/etc/auto.home',
options => '--timeout=120',
}
autofs::mount { 'smb':
mount => '/smb',
mapfile => 'program:/etc/auto.smb',
options => '--timeout=120',
}
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'manifests/mount.pp', line 59
define autofs::mount (
Variant[Stdlib::Absolutepath,Autofs::Mapentry] $mapfile,
Enum['present', 'absent'] $ensure = 'present',
Stdlib::Absolutepath $mount = $title,
Integer $order = 1,
Optional[String] $options = undef,
Stdlib::Absolutepath $master = $autofs::auto_master_map,
Stdlib::Absolutepath $map_dir = '/etc/auto.master.d',
Boolean $use_dir = false,
) {
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],
}
}
}
if !defined(Concat[$master]) {
concat { $master:
owner => $autofs::map_file_owner,
group => $autofs::map_file_group,
mode => '0644',
ensure_newline => true,
}
}
$contents = "${mount} ${mapfile} ${options}"
if $use_dir == false {
if $ensure == 'present' {
concat::fragment { "autofs::fragment preamble ${mount} ${mapfile}":
target => $master,
content => "${contents}\n",
order => $order,
}
} else {
# If the master map is being managed via other autofs::mount resources,
# too, at least one of which is ensured present, then this File_line is
# unnecessary. Otherwise, however, it is required for ensuring this
# mount absent to be effective.
file_line { "${master}::${mount}_${mapfile}":
ensure => 'absent',
path => $master,
match => "^\\s*${mount}\\s+${mapfile}\\s",
match_for_absence => true,
multiple => true,
notify => Service[$autofs::service_name],
}
}
} else {
# $use_dir == true
ensure_resource('file', $map_dir, {
ensure => directory,
owner => $autofs::map_file_owner,
group => $autofs::map_file_group,
mode => '0755',
purge => $autofs::purge_map_dir,
recurse => $autofs::purge_map_dir,
require => Class['autofs::package'],
}
)
if !defined(Concat::Fragment['autofs::fragment preamble map directory']) and $ensure == 'present' {
concat::fragment { 'autofs::fragment preamble map directory':
target => $master,
content => "+dir:${map_dir}",
order => $order,
require => File[$map_dir],
}
}
file { "${map_dir}/${name}.autofs":
ensure => $ensure,
owner => $autofs::map_file_owner,
group => $autofs::map_file_group,
mode => '0644',
content => "${contents}\n",
require => File[$map_dir],
}
}
}
|