Defined Type: autofs::mapfile

Defined in:
manifests/mapfile.pp

Summary

Defined type to manage overall autofs map files

Overview

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Whether the mapfile should be present on the target system

  • path (Stdlib::Absolutepath) (defaults to: $title)

    An absolute path to the map file

  • mappings (Array[Autofs::Fs_mapping]) (defaults to: [])

    an array of mappings to enroll in the file. Additional mappings can be specified for this mapfile via autofs::mapping resources

  • replace (Boolean) (defaults to: true)

    Whether to replace the contents of any an existing file at the specified path

  • execute (Boolean) (defaults to: false)

    Whether to make the mapfile executable or not

See Also:

Author:

  • Vox Pupuli <voxpupuli@groups.io>

  • David Hollinger III <david.hollinger@moduletux.com>



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
61
62
63
64
65
# File 'manifests/mapfile.pp', line 19

define autofs::mapfile (
  Enum['present', 'absent'] $ensure   = 'present',
  Stdlib::Absolutepath $path          = $title,
  Array[Autofs::Fs_mapping] $mappings = [],
  Boolean $replace                    = true,
  Boolean $execute                    = 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],
      }
    }
  }

  $mapfile_mode = $execute ? {
    true => '0755',
    false => '0644'
  }

  concat { $path:
    ensure  => $ensure,
    owner   => $autofs::map_file_owner,
    group   => $autofs::map_file_group,
    mode    => $mapfile_mode,
    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,
      }
    }
  }
}