Ansible Role mount

This role installs NFS and CIFS client utilities when necessary and configures mount points in /etc/fstab.

Tags

Tag

What it does

mount

Installs nfs-utils/cifs on RedHat-Based systems or nfs-common/cifs-utils on Debian-Based systems, creates the corresponding directories for the mount points, alters /etc/fstab und mounts the volumes

Optional Role Variables

Variable

Description

Default Value

mount__mounts__host_var /
mount__mounts__group_var

List of directories containing the mounts to create. Subkeys:

  • path: Mandatory, string. Path to the mount point.
  • src: Mandatory, string. Device (or NFS volume, or something else) to be mounted on path.
  • fstype: Mandatory, string. Filesystem type.
  • opts: Optional, string. Mount options, man fstab. Defaults to none.
  • state: Optional, string. Possible options: absent, absent_from_fstab, ephemeral, mounted, present, remounted or unmounted. Defaults to mounted. For details, have a look at the ansible.posix.mount module.

[]

Example:

# optional
mount__mounts__host_var:
  - path: '/mnt/nfs/data'
    fstype: 'nfs'
    src: 'nfs-server.example.com:/path/to/exported/data'
    opts: 'defaults'
    state: 'mounted'
  - path: '/mnt/cifs/data'
    fstype: 'cifs'
    src: '//cifs-server.example.com/CIFS-Share'
    opts: 'username=USERNAME,password=PASSWORD,vers=2.0,rw'
    state: 'mounted'
  - path: '/data'
    fstype: 'xfs'
    src: '/dev/sdb1'
    opts: 'defaults'
    state: 'mounted'

Troubleshooting

mount.nfs: access denied by server while mounting: Run exportfs -rv on the NFS server and try again.

License

The Unlicense

Author Information

Linuxfabrik GmbH, Zurich