salt.states.mount

Mounting of filesystems

Mount any type of mountable filesystem with the mounted function:

/mnt/sdb:
  mount.mounted:
    - device: /dev/sdb1
    - fstype: ext4
    - mkmnt: True
    - opts:
      - defaults

/srv/bigdata:
  mount.mounted:
    - device: UUID=066e0200-2867-4ebe-b9e6-f30026ca2314
    - fstype: xfs
    - opts: nobootwait,noatime,nodiratime,nobarrier,logbufs=8
    - dump: 0
    - pass_num: 2
    - persist: True
    - mkmnt: True

/var/lib/bigdata:
  mount.mounted:
    - device: /srv/bigdata
    - fstype: none
    - opts: bind
    - dump: 0
    - pass_num: 0
    - persist: True
    - mkmnt: True
salt.states.mount.fstab_absent(name, fs_file, mount_by=None, config=u'/etc/fstab')

Makes sure that a fstab mount point is absent.

name
The name of block device. Can be any valid fs_spec value.
fs_file
Mount point (target) for the filesystem.
mount_by
Select the final value for fs_spec. Can be [None, device, label, uuid, partlabel, partuuid]. If None, the value for fs_spect will be the parameter name, in other case will search the correct value based on the device name. For example, for uuid, the value for fs_spec will be of type 'UUID=xxx' instead of the device name set in name.
config
Place where the fstab file lives
salt.states.mount.fstab_present(name, fs_file, fs_vfstype, fs_mntops=u'defaults', fs_freq=0, fs_passno=0, mount_by=None, config=u'/etc/fstab', mount=True, match_on=u'auto')

Makes sure that a fstab mount point is pressent.

name
The name of block device. Can be any valid fs_spec value.
fs_file
Mount point (target) for the filesystem.
fs_vfstype
The type of the filesystem (e.g. ext4, xfs, btrfs, ...)
fs_mntops
The mount options associated with the filesystem. Default is defaults.
fs_freq
Field is used by dump to determine which fs need to be dumped. Default is 0
fs_passno
Field is used by fsck to determine the order in which filesystem checks are done at boot time. Default is 0
mount_by
Select the final value for fs_spec. Can be [None, device, label, uuid, partlabel, partuuid]. If None, the value for fs_spect will be the parameter name, in other case will search the correct value based on the device name. For example, for uuid, the value for fs_spec will be of type 'UUID=xxx' instead of the device name set in name.
config
Place where the fstab file lives. Default is /etc/fstab
mount
Set if the mount should be mounted immediately. Default is True
match_on
A name or list of fstab properties on which this state should be applied. Default is auto, a special value indicating to guess based on fstype. In general, auto matches on name for recognized special devices and device otherwise.
salt.states.mount.mod_watch(name, user=None, **kwargs)

The mounted watcher, called to invoke the watch command.

Note

This state exists to support special handling of the watch requisite. It should not be called directly.

Parameters for this function should be set by the state being triggered.

name
The name of the mount point
salt.states.mount.mounted(name, device, fstype, mkmnt=False, opts=u'defaults', dump=0, pass_num=0, config=u'/etc/fstab', persist=True, mount=True, user=None, match_on=u'auto', device_name_regex=None, extra_mount_invisible_options=None, extra_mount_invisible_keys=None, extra_mount_ignore_fs_keys=None, extra_mount_translate_options=None, hidden_opts=None, **kwargs)

Verify that a device is mounted

name
The path to the location where the device is to be mounted
device
The device name, typically the device node, such as /dev/sdb1 or UUID=066e0200-2867-4ebe-b9e6-f30026ca2314 or LABEL=DATA
fstype
The filesystem type, this will be xfs, ext2/3/4 in the case of classic filesystems, fuse in the case of fuse mounts, and nfs in the case of nfs mounts
mkmnt
If the mount point is not present then the state will fail, set mkmnt: True to create the mount point if it is otherwise not present
opts
A list object of options or a comma delimited list
dump
The dump value to be passed into the fstab, Default is 0
pass_num
The pass value to be passed into the fstab, Default is 0
config
Set an alternative location for the fstab, Default is /etc/fstab
persist
Set if the mount should be saved in the fstab, Default is True
mount
Set if the mount should be mounted immediately, Default is True
user
The account used to execute the mount; this defaults to the user salt is running as on the minion
match_on
A name or list of fstab properties on which this state should be applied. Default is auto, a special value indicating to guess based on fstype. In general, auto matches on name for recognized special devices and device otherwise.
device_name_regex

A list of device exact names or regular expressions which should not force a remount. For example, glusterfs may be mounted with a comma-separated list of servers in fstab, but the /proc/self/mountinfo will show only the first available server.

{% set glusterfs_ip_list = ['10.0.0.1', '10.0.0.2', '10.0.0.3'] %}

mount glusterfs volume:
  mount.mounted:
    - name: /mnt/glusterfs_mount_point
    - device: {{ glusterfs_ip_list|join(',') }}:/volume_name
    - fstype: glusterfs
    - opts: _netdev,rw,defaults,direct-io-mode=disable
    - mkmnt: True
    - persist: True
    - dump: 0
    - pass_num: 0
    - device_name_regex:
      - ({{ glusterfs_ip_list|join('|') }}):/volume_name

New in version 2016.11.0.

extra_mount_invisible_options

A list of extra options that are not visible through the /proc/self/mountinfo interface.

If a option is not visible through this interface it will always remount the device. This option extends the builtin mount_invisible_options list.

extra_mount_invisible_keys

A list of extra key options that are not visible through the /proc/self/mountinfo interface.

If a key option is not visible through this interface it will always remount the device. This option extends the builtin mount_invisible_keys list.

A good example for a key option is the password option:

password=badsecret
extra_mount_ignore_fs_keys

A dict of filesystem options which should not force a remount. This will update the internal dictionary. The dict should look like this:

{
    'ramfs': ['size']
}
extra_mount_translate_options

A dict of mount options that gets translated when mounted. To prevent a remount add additional options to the default dictionary. This will update the internal dictionary. The dictionary should look like this:

{
    'tcp': 'proto=tcp',
    'udp': 'proto=udp'
}
hidden_opts

A list of mount options that will be ignored when considering a remount as part of the state application

New in version 2015.8.2.

salt.states.mount.swap(name, persist=True, config=u'/etc/fstab')

Activates a swap device

/root/swapfile:
  mount.swap

Note

swap does not currently support LABEL

salt.states.mount.unmounted(name, device=None, config=u'/etc/fstab', persist=False, user=None, **kwargs)

New in version 0.17.0.

Verify that a device is not mounted

name
The path to the location where the device is to be unmounted from
device

The device to be unmounted. This is optional because the device could be mounted in multiple places.

New in version 2015.5.0.

config
Set an alternative location for the fstab, Default is /etc/fstab
persist
Set if the mount should be purged from the fstab, Default is False
user
The user to own the mount; this defaults to the user salt is running as on the minion