Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i create a zfs filesystem/zpool using ansible using zfs-linux

Tags:

linux

ansible

zfs

I want the equivalent of the following to be generated using the zfs module in ansible, the following works using the command line, but fails on second run as the filesystem already exists.

{{ part_postgres }} is set to /dev/sdb in this instance.

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

Currently in ansible I have:

- name: Create postgres zpool
    zfs: name=postgres{{ part_postgres }}
         compression=gzip
         state=present
         secondarycache=all
         mountpoint=/postgres
         atime=off
like image 745
Damian Avatar asked Mar 22 '23 16:03

Damian


1 Answers

Ok - the zfs module won't do it, would need to write a new model for zpool. That said, its easy enough to check for zpool existing using the 'creates' annotation for the command module in ansible:

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

This will check if /postgres exists, and only run the command if it doesn't.

like image 66
Damian Avatar answered Apr 10 '23 09:04

Damian