linux - 我如何使用 zfs-linux 使用 ansible 创建 zfs 文件系统/zpool

标签 linux ansible zfs

我希望使用 ansible 中的 zfs 模块生成以下等价物,以下使用命令行工作,但在第二次运行时失败,因为文件系统已经存在。

{{ part_postgres }} 在此实例中设置为/dev/sdb。

zpool create -O compression=gzip postgres {{ part_postgres }} -O secondarycache=all

目前在ansible中我有:

- name: Create postgres zpool
    zfs: name=postgres{{ part_postgres }}
         compression=gzip
         state=present
         secondarycache=all
         mountpoint=/postgres
         atime=off

最佳答案

好的 - zfs 模块不会这样做,需要为 zpool 编写一个新模型。也就是说,在 ansible 中使用命令模块的“创建”注释来检查是否存在 zpool 非常容易:

  - name: Create postgres zpool
    command: zpool create -O compression=gzip postgres /dev/sdb -o ashift=12 -O    secondarycache=all
             creates=/postgres

这将检查/postgres 是否存在,如果不存在则只运行该命令。

关于linux - 我如何使用 zfs-linux 使用 ansible 创建 zfs 文件系统/zpool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19938439/

相关文章:

ansible - 保留缩进和换行符时的YAML多行字符串

linux - 用于检查最新 ZFS 快照的 Shell 脚本

shell - 解析 zpool 中的磁盘

linux - 命令 'xlsatoms' 显示什么?

list - 从列表中提取元素并将其设置为变量 (set_fact)

c++ - 如何从另一个线程唤醒没有超时时间的 Select 调用

ssh - Ansible bitbucket 克隆配置 ssh 错误

linux - 如何挂载在不同磁盘上创建的 zfs 池

linux - 无法正确读取 Bash 中的文件

c - linux中的信号量操作,收到SIGSEGV和segmentation fault,哪一部分出错了?