arensb.truenas.jail_fstab module – Manage a jail’s fstab

Note

This module is part of the arensb.truenas collection (version 1.11.4).

To install it, use: ansible-galaxy collection install arensb.truenas.

To use it in a playbook, specify: arensb.truenas.jail_fstab.

New in arensb.truenas 1.9.0

Synopsis

  • Add, remove, mount, and unmount filesystems that a jail sees.

  • Note that changes can only be made when the jail is stopped, so this module will attempt to stop the jail if it needs to, and then restart it after the changes are made.

  • If you do not want production jails to be restarted without your explicit approval, you can add a clause like check_mode: "{{ restart_jails != 'yes' }}"

Parameters

Parameter

Comments

append

boolean

If yes, other filesystems may be mounted besides the ones listed in fstab.

If no, any mounts other than the ones in fstab will be removed.

Choices:

  • false ← (default)

  • true

fstab

list / elements=string

List of mount points. Each element is a dictionary.

Most people will only need to specify src, mount, and options. The rest are advanced options.

dump

integer

Used by the dump command. This field gives the number of days between backups. A value of 0 means “no backups”.

This is the fs_freq field in fstab(5).

For a jail, this will typically be 0.

Default: 0

fsck_pass

integer

Used by fsck to determine the order in which to check filesystems at boot time.

This is not normally useful in a jail. It is included here for completeness.

Default: 0

fstype

string

Filesystem type.

When mounting an existing directory, use nullfs.

Default: "nullfs"

mount

string / required

The directory where the device should be mounted.

This is a relative path, relative to the jail’s root, typically /mnt/<pool>/iocage/jails/<jail-name>/root.

options

string

Filesystem options to pass to mount. Comma-separated string.

The most common values are ro (read-only) and rw (read-write).

Default: "ro"

src

string / required

The device to mount, or the directory to share with the jail.

state

string

Whether the filesystem should be mounted or not.

Set state to absent to ensure that nothing is mounted at a given mount point.

By default, filesystems are mounted, because it is assumed that you want them available. In addition, setting append to no ensures that any filesystems not on the list are unmounted.

When state is present, the source parameter is required. When state is absent, source can be omitted.

Choices:

  • "present" ← (default)

  • "absent"

jail

string / required

Name of the jail

Examples

- name: Mount some directories inside a jail
  arensb.truenas.jail_fstab:
    jail: the-jail-name
    fstab:
      - src: /mnt/data/my-data
        mount: /my-data
        fstype: nullfs
        options: ro
        dump: 0
        pass: 0
      - src: /mnt/data/more-data
        mount: /data/more

# Making changes to fstab involves stopping the jail, then restarting it.
# This shows how to not affect running services unless the 'bounce_jails'
# variable is set to 'yes'.
- name: Don't halt production services
  arensb.truenas.jail_fstab:
    jail: the-jail-name
    fstab:
      - src: /mnt/data/my-data
        mount: /my-data
  check_mode: "{{ ansible_check_mode or bounce_jails != 'yes' }}"

- name: Ensure that a filesystem is *not* mounted:
  arensb.truenas.jail_fstab:
    jail: the-jail-name
    fstab:
        - mount: /old-data
          state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

changes

list / elements=string

In check mode, this is a detailed list of changed that would be made.

Returned: success

fstab

dictionary

The fstab of the jail fstab. This is a dict of elements of the form {"IDX": [source, destination, fstype, fsoptions, dump, pass], "type": "USER"}

IDX is an integer string: the position of the entry in its fstab, zero-based.

source is the device being mounted, or the directory being shared with the jail.

destination is the directory where the filesystem is mounted. This is an absolute path as seen from outside the jail.

fstype is the mount’s filesystem type. For a null mount (filesystem shared with the jail), this is nullfs.

fsoptions are the options passed to mount.

dump and pass are the dump and pass values from the fstab entry.

type specifies whether this is a system or user filesystem. In this module, it is always "USER".

fstab is returned in check mode as well.

Returned: success

status

list / elements=string

This module may affect multiple filesystems. status is a list of results, one for each change made.

For a successful change, this is typically True.

Returned: success