- name: install zfs
  apt:
    pkg:
      - dkms
      - zfs-dkms
      - zfsutils-linux

- name: copy zfs unlock systemd service
  copy:
    src: zfs-load-key.service
    dest: /etc/systemd/system/zfs-load-key.service
    owner: root
    group: root
    mode: 0644

- name: enable systemd unlock service
  ansible.builtin.systemd:
    name: zfs-load-key.service
    enabled: True
    daemon_reload: True

- name: create volumes
  loop: "{{ zfs.volumes|dict2items }}"
  include_tasks: volume.yml