zfs

Manage ZFS datasets statefully.

Example

test/shares/yuki:
  zfs.filesystem_present:
    - create_parent: true
    - properties:
        quota: 16G

test/iscsi/haruhi:
  zfs.volume_present:
    - create_parent: true
    - volume_size: 16M
    - sparse: true
    - properties:
        readonly: on

test/shares/yuki@frozen:
  zfs.snapshot_present

moka_origin:
  zfs.hold_present:
    - snapshot: test/shares/yuki@frozen

test/shares/moka:
  zfs.filesystem_present:
    - cloned_from: test/shares/yuki@frozen

test/shares/moka@tsukune:
  zfs.snapshot_absent
saltext.zfs.states.zfs.filesystem_absent(name, force=False, recursive=False)[source]

Ensure a filesystem is absent from the system.

namestring

name of filesystem

forceboolean

try harder to destroy the dataset (zfs destroy -f)

recursiveboolean

also destroy all the child datasets (zfs destroy -r)

Warning

If a volume with name exists, this state will succeed without destroying the volume specified by name. This module is dataset type sensitive.

saltext.zfs.states.zfs.volume_absent(name, force=False, recursive=False)[source]

Ensure a volume is absent from the system.

namestring

name of volume

forceboolean

try harder to destroy the dataset (zfs destroy -f)

recursiveboolean

also destroy all the child datasets (zfs destroy -r)

Warning

If a filesystem with name exists, this state will succeed without destroying the filesystem specified by name. This module is dataset type sensitive.

saltext.zfs.states.zfs.snapshot_absent(name, force=False, recursive=False)[source]

Ensure a snapshot is absent from the system.

namestring

name of snapshot

forceboolean

try harder to destroy the dataset (zfs destroy -f)

recursiveboolean

also destroy all the child datasets (zfs destroy -r)

saltext.zfs.states.zfs.bookmark_absent(name, force=False, recursive=False)[source]

Ensure a bookmark is absent from the system.

namestring

name of snapshot

forceboolean

try harder to destroy the dataset (zfs destroy -f)

recursiveboolean

also destroy all the child datasets (zfs destroy -r)

saltext.zfs.states.zfs.hold_absent(name, snapshot, recursive=False)[source]

Ensure a hold is absent from the system.

namestring

name of hold

snapshotstring

name of snapshot

recursiveboolean

recursively releases a hold with the given tag on the snapshots of all descendent filesystems.

saltext.zfs.states.zfs.hold_present(name, snapshot, recursive=False)[source]

Ensure a hold is present on the system.

namestring

name of holdt

snapshotstring

name of snapshot

recursiveboolean

recursively add hold with the given tag on the snapshots of all descendent filesystems.

saltext.zfs.states.zfs.filesystem_present(name, create_parent=False, properties=None, cloned_from=None)[source]

Ensure a filesystem exists and has properties set.

namestring

name of filesystem

create_parentboolean

creates all the non-existing parent datasets. any property specified on the command line using the -o option is ignored.

cloned_fromstring

name of snapshot to clone

propertiesdict

additional zfs properties (-o)

Note

cloned_from is only use if the filesystem does not exist yet, when cloned_from is set after the filesystem exists it will be ignored.

Note

Properties do not get cloned, if you specify the properties in the state file they will be applied on a subsequent run.

saltext.zfs.states.zfs.volume_present(name, volume_size, sparse=False, create_parent=False, properties=None, cloned_from=None)[source]

Ensure a volume exists and has properties set.

namestring

name of volume

volume_sizestring

size of volume

sparseboolean

create sparse volume

create_parentboolean

creates all the non-existing parent datasets. any property specified on the command line using the -o option is ignored.

cloned_fromstring

name of snapshot to clone

propertiesdict

additional zfs properties (-o)

Note

cloned_from is only use if the volume does not exist yet, when cloned_from is set after the volume exists it will be ignored.

Note

Properties do not get cloned, if you specify the properties in the state file they will be applied on a subsequent run.

volume_size is considered a property, so the volume’s size will be corrected when the properties get updated if it differs from the original volume.

The sparse parameter is ignored when using cloned_from.

saltext.zfs.states.zfs.bookmark_present(name, snapshot)[source]

Ensure a bookmark exists.

namestring

name of bookmark

snapshotstring

name of snapshot

saltext.zfs.states.zfs.snapshot_present(name, recursive=False, properties=None)[source]

Ensure a snapshot exists and has properties set.

namestring

name of snapshot

recursiveboolean

recursively create snapshots of all descendent datasets

propertiesdict

additional zfs properties (-o)

saltext.zfs.states.zfs.promoted(name)[source]

Ensure a dataset is not a clone.

namestring

name of fileset or volume

Warning

only one dataset can be the origin, if you promote a clone the original will now point to the promoted dataset

saltext.zfs.states.zfs.scheduled_snapshot(name, prefix, recursive=True, schedule=None)[source]

Maintain a set of snapshots based on a schedule.

namestring

name of filesystem or volume

prefixstring

prefix for the snapshots e.g. ‘test’ will result in snapshots being named ‘test-yyyymmdd_hhmm’

recursiveboolean

create snapshots for all children also

scheduledict

dict holding the schedule, the following keys are available (minute, hour, day, month, and year) by default all are set to 0 the value indicated the number of snapshots of that type to keep around.

Warning

snapshots will only be created and pruned every time the state runs. a schedule must be setup to automatically run the state. this means that if you run the state daily the hourly snapshot will only be made once per day!