salt.states.zpool

States for managing zpools

maintainer:

Jorge Schrauwen <sjorge@blackdot.be>

maturity:

new

depends:

salt.utils.zfs, salt.modules.zpool

platform:

smartos, illumos, solaris, freebsd, linux

New in version 2016.3.0.

Changed in version 2018.3.1: Big refactor to remove duplicate code, better type conversions and improved consistency in output.

oldpool:
  zpool.absent:
    - export: true

newpool:
  zpool.present:
    - config:
        import: false
        force: true
    - properties:
        comment: salty storage pool
    - layout:
        - mirror:
          - /dev/disk0
          - /dev/disk1
        - mirror:
          - /dev/disk2
          - /dev/disk3

partitionpool:
  zpool.present:
    - config:
        import: false
        force: true
    - properties:
        comment: disk partition salty storage pool
        ashift: '12'
        feature@lz4_compress: enabled
    - filesystem_properties:
        compression: lz4
        atime: on
        relatime: on
    - layout:
        - /dev/disk/by-uuid/3e43ce94-77af-4f52-a91b-6cdbb0b0f41b

simplepool:
  zpool.present:
    - config:
        import: false
        force: true
    - properties:
        comment: another salty storage pool
    - layout:
        - /dev/disk0
        - /dev/disk1

Warning

The layout will never be updated, it will only be used at time of creation. It's a whole lot of work to figure out if a devices needs to be detached, removed, etc. This is best done by the sysadmin on a case per case basis.

Filesystem properties are also not updated, this should be managed by the zfs state module.

salt.states.zpool.absent(name, export=False, force=False)

ensure storage pool is absent on the system

namestring

name of storage pool

exportboolean

export instead of destroy the zpool if present

forceboolean

force destroy or export

salt.states.zpool.present(name, properties=None, filesystem_properties=None, layout=None, config=None)

ensure storage pool is present on the system

namestring

name of storage pool

propertiesdict

optional set of properties to set for the storage pool

filesystem_propertiesdict

optional set of filesystem properties to set for the storage pool (creation only)

layout: dict

disk layout to use if the pool does not exist (creation only)

configdict

fine grain control over this state

Note

The following configuration properties can be toggled in the config parameter.
  • import (true) - try to import the pool before creating it if absent

  • import_dirs (None) - specify additional locations to scan for devices on import (comma-separated)

  • device_dir (None, SunOS=/dev/dsk, Linux=/dev) - specify device directory to prepend for none absolute device paths

  • force (false) - try to force the import or creation

Note

It is no longer needed to give a unique name to each top-level vdev, the old layout format is still supported but no longer recommended.

- mirror:
  - /tmp/vdisk3
  - /tmp/vdisk2
- mirror:
  - /tmp/vdisk0
  - /tmp/vdisk1

The above yaml will always result in the following zpool create:

zpool create mypool mirror /tmp/vdisk3 /tmp/vdisk2 mirror /tmp/vdisk0 /tmp/vdisk1

Warning

The legacy format is also still supported but not recommended, because ID's inside the layout dict must be unique they need to have a suffix.

mirror-0:
  /tmp/vdisk3
  /tmp/vdisk2
mirror-1:
  /tmp/vdisk0
  /tmp/vdisk1

Warning

Pay attention to the order of your dict!

- mirror:
  - /tmp/vdisk0
  - /tmp/vdisk1
- /tmp/vdisk2

The above will result in the following zpool create:

zpool create mypool mirror /tmp/vdisk0 /tmp/vdisk1 /tmp/vdisk2

Creating a 3-way mirror! While you probably expect it to be mirror root vdev with 2 devices + a root vdev of 1 device!