W3cubDocs

/Ansible

mount - Control active and configured mount points

Synopsis

This module controls active and configured mount points in /etc/fstab.

Options

parameter required default choices comments
boot
(added in 2.2)
no True
  • yes
  • no
Determines if the filesystem should be mounted on boot.
Only applies to Solaris systems.
dump
no
Dump (see fstab(5)). Note that if set to null and state set to present, it will cease to work and duplicate entries will be made with subsequent runs.
Has no effect on Solaris systems.
fstab
no /etc/fstab (/etc/vfstab on Solaris)
File to use instead of /etc/fstab. You shouldn't use that option unless you really know what you are doing. This might be useful if you need to configure mountpoints in a chroot environment.
fstype
no
Filesystem type. Required when state is present or mounted.
name
yes
Path to the mount point (e.g. /mnt/files)
opts
no
Mount options (see fstab(5), or vfstab(4) on Solaris).
passno
no
Passno (see fstab(5)). Note that if set to null and state set to present, it will cease to work and duplicate entries will be made with subsequent runs.
Deprecated on Solaris systems.
src
no
Device to be mounted on name. Required when state set to present or mounted.
state
yes
  • present
  • absent
  • mounted
  • unmounted
If mounted or unmounted, the device will be actively mounted or unmounted as needed and appropriately configured in fstab.
absent and present only deal with fstab but will not affect current mounting.
If specifying mounted and the mount point is not present, the mount point will be created.
Similarly, specifying absent will remove the mount point directory.

Examples

- name: Mount DVD read-only
  mount:
    name: /mnt/dvd
    src: /dev/sr0
    fstype: iso9660
    opts: ro
    state: present

- name: Mount up device by label
  mount:
    name: /srv/disk
    src: LABEL=SOME_LABEL
    fstype: ext4
    state: present

- name: Mount up device by UUID
  mount:
    name: /home
    src: UUID=b3e48f45-f933-4c8e-a700-22a159ec9077
    fstype: xfs
    opts: noatime
    state: present

This is a Core Module

For more information on what this means please read Core Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/mount_module.html