community.general.zfs 模块 – 管理 zfs

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定: community.general.zfs

概要

  • 管理 ZFS 文件系统、卷、克隆和快照

参数

参数

注释

extra_zfs_properties

字典

要设置的 zfs 属性的字典。

有关详细信息,请参阅 zfs(8) 手册页。

默认值: {}

name

字符串 / 必需

文件系统、快照或卷名称,例如 rpool/myfs

origin

字符串

用于创建克隆的快照。

state

字符串 / 必需

是否创建(present)或删除(absent)文件系统、快照或卷。 将根据需要创建/销毁所有父级/子级,以达到所需状态。

选项

  • "absent"

  • "present"

属性

属性

支持

描述

check_mode

支持: 部分

在某些情况下,它可能会报告任务已更改,但在禁用 check_mode 时不会报告为已更改。

例如,当设置了 zpool altroot 选项时,或者当使用人类可读的符号(例如 1M1024K)而不是作为不合格的字节计数(例如 1048576)写入大小时,可能会发生这种情况。

可以在 check_mode 中运行并返回更改的状态预测,而无需修改目标。

diff_mode

支持: 完全

当处于 diff 模式时,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

示例

- name: Create a new file system called myfs in pool rpool with the setuid property turned off
  community.general.zfs:
    name: rpool/myfs
    state: present
    extra_zfs_properties:
      setuid: 'off'

- name: Create a new volume called myvol in pool rpool.
  community.general.zfs:
    name: rpool/myvol
    state: present
    extra_zfs_properties:
      volsize: 10M

- name: Create a snapshot of rpool/myfs file system.
  community.general.zfs:
    name: rpool/myfs@mysnapshot
    state: present

- name: Create a new file system called myfs2 with snapdir enabled
  community.general.zfs:
    name: rpool/myfs2
    state: present
    extra_zfs_properties:
      snapdir: enabled

- name: Create a new file system by cloning a snapshot
  community.general.zfs:
    name: rpool/cloned_fs
    state: present
    origin: rpool/myfs@mysnapshot

- name: Destroy a filesystem
  community.general.zfs:
    name: rpool/myfs
    state: absent

作者

  • Johan Wiren (@johanwiren)