Defined Type: autofs::mount

Defined in:
manifests/mount.pp

Overview

Define: autofs::mount

Defined type to generate autofs mount point configuration files.

Examples:

Using the autofs::mount defined type to setup automount for user home directories.

autofs::mount { 'home':
  mount       => '/home',
  mapfile     => '/etc/auto.home',
  mapcontents => ['* -user,rw,soft,intr,rsize=32768,wsize=32768,tcp,nfsvers=3,noacl server.example.com:/path/to/home/shares'],
  options     => '--timeout=120',
  order       => 01
}

Parameters:

  • mount (String)

    Location where you will mount the remote NFS Share.

  • mapfile (String) (defaults to: '')

    Name of the "auto." configuration file that will be generated.

  • mapcontents (Array) (defaults to: [])

    The mount point options and parameters. Example: '* -user,rw,soft server.example.com:/path/to/home/shares'

  • master (String) (defaults to: '/etc/auto.master')

    Full path, including filename, to the autofs master file.

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

    Full path, including directory name, to the autofs master configuration directory. Only required if use_dir is set to true.

  • use_dir (Boolean) (defaults to: false)

    If true, autofs will look for master configuration in the map_dir path using filenames ending in the ".autofs" extension.

  • options (String) (defaults to: '')

    Options for the autofs mount point within in the auto.master.

  • order (Integer)

    Order in which entries will appear in the autofs master file.

  • direct (Boolean) (defaults to: true)

    Boolean to allow for indirect map. Defaults to true to be backwards compatible.

  • execute (Boolean) (defaults to: false)

    If true, it will make the $mapfile an executable script, otherwise the file is a standard "auto." configuration file.

  • replace (Boolean) (defaults to: true)

    Set to false if you only want to place the file if it is missing.

See Also:

Author:



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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'manifests/mount.pp', line 39

define autofs::mount (
  String $mount,
  Integer $order,
  String $options    = '',
  String $master     = '/etc/auto.master',
  String $map_dir    = '/etc/auto.master.d',
  Boolean $use_dir   = false,
  Boolean $direct    = true,
  Boolean $execute   = false,
  String $mapfile    = '',
  Array $mapcontents = [],
  Boolean $replace   = true
) {

  if $mapfile != '' {
    $contents = "${mount} ${mapfile} ${options}\n"
  } else {
    $contents = "${mount} ${options}\n"
  }

  if $execute {
    $mapperms = '0755'
    $maptempl = 'autofs/auto.map.exec.erb'
  }
  else {
    $mapperms = '0644'
    $maptempl = 'autofs/auto.map.erb'
  }

  if !defined(Concat[$master]) {
    concat { $master:
      owner          => 'root',
      group          => 'root',
      mode           => '0644',
      ensure_newline => true,
      notify         => Service[ 'autofs' ],
    }
  }

  if $use_dir == false {
    concat::fragment { "autofs::fragment preamble ${mount} ${mapfile}":
      target  => $master,
      content => $contents,
      order   => $order,
    }
  } else {
    ensure_resource('file', $map_dir, {
      'ensure'  => 'directory',
      'owner'   => 'root',
      'group'   => 'root',
      'mode'    => '0755',
      'require' => Package['autofs'],
    })

    if !defined(Concat::Fragment['autofs::fragment preamble map directory']) {
      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  => present,
      owner   => 'root',
      group   => 'root',
      mode    => $mapperms,
      content => $contents,
      require => File[ $map_dir ],
      notify  => Service[ 'autofs' ],
    }
  }

  if $mapfile != '' {
    file { $mapfile:
      ensure  => present,
      owner   => 'root',
      group   => 'root',
      mode    => $mapperms,
      replace => $replace,
      content => template($maptempl),
      require => Package[ 'autofs' ],
      notify  => Service[ 'autofs' ],
    }
  }

}