``profile::mounter``
====================

This module manages mounts and installs filesystem-specific utilities.

Mounts are configured using the Puppet ``mount`` resource type, ie. they get
added to ``/etc/fstab``. Auto-mounts are implemented by adding the
``x-systemd.automount`` option.


Parameters
----------

===============================  ========  ================================================
**Name**                         **Type**  **Default**
-------------------------------  --------  ------------------------------------------------
mounts                           Array     []
def::$NAME                       Hash      None
cifs_files                       Array     []
cifs::def::$NAME                 Hash      None
===============================  ========  ================================================


``mounter::def::$NAME``
~~~~~~~~~~~~~~~~~~~~~~~

A hash defining a mount ``$NAME`` which can then be referenced by a module or
through the Hiera variable ``mounter::mounts``.

The hash may contain the following keys:

- ensure

  Is passed to the ``mount`` resource type unaltered with the following
  exception. If the value is ``running``, it is changed to ``mounted``. This
  ensures compatibility with an older version of this module.

- mountpoint

  Will be created, if necessary.

- device
- options
- type

  The filesystem type. Passed to the ``mount`` resource as ``fstype``.

- auto

  Whether or not this mount should be automounted. Default: ``false``.

- updatedb

  A boolean specifying whether :manpage:`updatedb(8)` should index the files
  below the mountpoint. See the :doc:`updatedb <../components/updatedb>`
  module for details.


``mounter::mounts``
~~~~~~~~~~~~~~~~~~~

An array of strings referring to mount definitions to be configured on the
target system. Each string is the name of a mount defined through
`mounter::def::$NAME`_.

``mounter::cifs::def::$NAME``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A ``Hash`` containing information for creating an authentication file for CIFS
mounts.

The ``Hash`` may contain the following keys:

- ensure
  
  Is passwed to the ``profile::mounter::cifs`` resource, should contain any
  possible value for the attribut ``ensure`` in a ``File`` resource type.
  Usually, ``present`` will ensure that file is existing and updated will
  ``absent`` will remove it.

- path
  
  This is mandatory, should contain the path where the new credential file 
  should be located. Usually, ``/etc/cifs-utils`` would be a good option.

- mode
  
  Defaults to ``0400``. It can be changed.

- owner

  Defaults to ``root`` user. It can be changed.

- group

  Defaults to ``group`` user. It can be changed.

- cifs_username

  Must be defined. Should contain the ``username`` of the user allowed to 
  mount the CIFS mountpoint.

- cifs_password

  Must be defined. Should contain the ``password`` of the user allowed to 
  mount the CIFS mountpoint, defined with ``cifs_username``.


``mounter::cifs``
~~~~~~~~~~~~~~~~~

This defined type takes the paremters accepted for CIFS definitions (see
`mounter::cifs::def::$NAME`_).


Defined Types
-------------

``mount``
~~~~~~~~~

This defined type takes the parameters accepted for mount definitions (see
`mounter::def::$NAME`_).


Examples
--------

Local mount
~~~~~~~~~~~

A local mount can be configured in the following way::

  mounter::def::scratch:
    ensure: 'mounted'
    mountpoint: '/scratch'
    device: '/dev/vg_data/lv_scratch'
    type: 'xfs'

  mounter::mounts:
    - 'scratch'


To have the ``scratch`` mount from the previous example auto-mounted instead,
add the ``auto`` parameter::

  mounter::def::scratch:
    ensure: 'mounted'
    mountpoint: '/scratch'
    device: '/dev/vg_data/lv_scratch'
    type: 'xfs'
    auto: true

  mounter::mounts:
    - 'scratch'


Supposedly this is a scratch mount, so we exclude the whole mount both from
backups and from updatedb.

Remote Mount
~~~~~~~~~~~~

Remote CIFS mountpoint can be defined as follows::

  mounter::cifs::def::cifs_mpc2375:
    ensure: 'present'
    path: '/etc/cifs-utils'
    cifs_username: 'allowedWindowsUser'
    cifs_password: 'ENC[PKCS7,MIIBeQYJKoZIhvc...]'
  
  mounter::cifs::files: 
    - 'cifs_mpc2375'
  
  mounter::def::emf: 
    ensure: 'running'
    enable: 'true'
    device: '//172.23.75.16/Users'
    mountpoint: '/emf/jeol2200fs/k2'
    type: 'cifs'
    options: 'credentials=/etc/cifs-utils/cifs_mpc2375,uid=35667,gid=35270,forcegid,file_mode=0660,dir_mode=0770'
  
  mounter::mounts: 
    - 'emf'
 
In the above example, we need to create a ``credentials`` file with `mounter::cifs::def::$NAME`_. This file will
be called ``cifs_mpc2375`` and will be located in ``/etc/cifs-utils`` and will contain information about the 
username and password allowed to mount it.

On the other hand, a mount ``emf`` is defined. You should specify in options the location of ``credentials``. 
Other optional parameters are used. ``emf`` is mounted with type ``cifs``, which will automatically ensure that
proper ``cifs-utils`` package is installed.
