Ansible Role mount

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

Runs on

  • RHEL 7 (and compatible)

  • RHEL 8 (and compatible)

  • Debian 11 (and compatible)

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
  • src
  • fstype
  • opts
  • state
For details, have a look at the ansible.posix.mount_module.

unset

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