ansible.posix.mount – Control active and configured mount points
ansible.posix.mount – Control active and configured mount points
Note
This plugin is part of the ansible.posix collection (version 1.1.1).
To install it use: ansible-galaxy collection install ansible.posix
.
To use it in a playbook, specify: ansible.posix.mount
.
New in version 1.0.0: of ansible.posix
Synopsis
- This module controls active and configured mount points in
/etc/fstab
.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
backup boolean |
|
Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. |
boot boolean |
|
Determines if the filesystem should be mounted on boot. Only applies to Solaris systems. |
dump string |
Default: 0 |
Dump (see fstab(5)). Note that if set to Has no effect on Solaris systems. |
fstab string |
File to use instead of You should not use this option unless you really know what you are doing. This might be useful if you need to configure mountpoints in a chroot environment. OpenBSD does not allow specifying alternate fstab files with mount so do not use this on OpenBSD with any state that operates on the live filesystem. This parameter defaults to /etc/fstab or /etc/vfstab on Solaris. | |
fstype string |
Filesystem type. Required when state is | |
opts string |
Mount options (see fstab(5), or vfstab(4) on Solaris). | |
passno string |
Default: 0 |
Passno (see fstab(5)). Note that if set to Deprecated on Solaris systems. |
path path / required |
Path to the mount point (e.g. Before Ansible 2.3 this option was only usable as dest, destfile and name.
| |
src path |
Device (or NFS volume, or something else) to be mounted on path. Required when state set to | |
state string / required |
|
If If
|
Notes
Note
- As of Ansible 2.3, the name option has been changed to path as default, but name still works as well.
- Using
remounted
with opts set may create unexpected results based on the existing options already defined on mount, so care should be taken to ensure that conflicting options are not present before hand.
Examples
# Before 2.3, option 'name' was used instead of 'path'
- name: Mount DVD read-only
ansible.posix.mount:
path: /mnt/dvd
src: /dev/sr0
fstype: iso9660
opts: ro,noauto
state: present
- name: Mount up device by label
ansible.posix.mount:
path: /srv/disk
src: LABEL=SOME_LABEL
fstype: ext4
state: present
- name: Mount up device by UUID
ansible.posix.mount:
path: /home
src: UUID=b3e48f45-f933-4c8e-a700-22a159ec9077
fstype: xfs
opts: noatime
state: present
- name: Unmount a mounted volume
ansible.posix.mount:
path: /tmp/mnt-pnt
state: unmounted
- name: Remount a mounted volume
ansible.posix.mount:
path: /tmp/mnt-pnt
state: remounted
# The following will not save changes to fstab, and only be temporary until
# a reboot, or until calling "state: unmounted" followed by "state: mounted"
# on the same "path"
- name: Remount a mounted volume and append exec to the existing options
ansible.posix.mount:
path: /tmp
state: remounted
opts: exec
- name: Mount and bind a volume
ansible.posix.mount:
path: /system/new_volume/boot
src: /boot
opts: bind
state: mounted
fstype: none
- name: Mount an NFS volume
ansible.posix.mount:
src: 192.168.1.100:/nfs/ssd/shared_data
path: /mnt/shared_data
opts: rw,sync,hard,intr
state: mounted
fstype: nfs
Authors
- Ansible Core Team
- Seth Vidal (@skvidal)
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/posix/mount_module.html