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',
}

Examples:

Declaring an autofs mount point for automounting user home directories. (The

corresponding map file needs to be managed separately.)

Declaring a mount point with an executable map (to be managed

separately, if needed).

Remove an entry from the master map (the map file is unaffected)

autofs::mount { '/smb':
  ensure  => 'absent',
  mapfile => 'program:/etc/auto.smb',
}

Parameters:

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

    Whether a definition of this mount point should be present in the master map. (default: ‘present’)

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

    The absolute path of the Autofs mount point being managed. For a direct map, this should be ‘/-’. Otherwise, it designates the parent directory of the filesystem mount points managed by the map assigned to this Autofs mount point. (default: the title of this resource)

  • mapfile (Variant[Stdlib::Absolutepath,Autofs::Mapentry])

    a designation for the Autofs map associated with this mount point. Typically, this is an absolute path to a map file, whose base name conventionally begins with “auto.”, but Autofs recognizes other alternatives, too, that can be specified via this parameter.

  • master (Stdlib::Absolutepath) (defaults to: $autofs::auto_master_map)

    Full path, including filename, to the autofs master map. Usually the correct master map will be chosen automatically, and you will not need to specify this.

  • map_dir (Stdlib::Absolutepath) (defaults to: '/etc/auto.master.d')

    Full path, including directory name, to the autofs master map’s drop-in directory. Relevant only when $use_dir is true. (default: ‘/etc/auto.master.d’).

  • use_dir (Boolean) (defaults to: false)

    If true, autofs will manage this mount via a file in the master map’s drop-in directory instead of directly in the master map. The master map will still be managed, however, to ensure at least that it enables the (correct) drop-in directory.

  • options (Optional[String]) (defaults to: undef)

    Options to be specified for the autofs mount point within the master map.

  • order (Integer) (defaults to: 1)

    The relative order in which entries will appear in the master map. Irrelevant when $use_dir is true.

See Also:

Author:

  • Vox Pupuli <voxpupuli@groups.io>

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



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],
    }
  }
}