summaryrefslogtreecommitdiff
path: root/roles/zfs/base/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/zfs/base/tasks/main.yml')
-rw-r--r--roles/zfs/base/tasks/main.yml10
1 files changed, 8 insertions, 2 deletions
diff --git a/roles/zfs/base/tasks/main.yml b/roles/zfs/base/tasks/main.yml
index ad5d1ce2..db5cfe2d 100644
--- a/roles/zfs/base/tasks/main.yml
+++ b/roles/zfs/base/tasks/main.yml
@@ -26,10 +26,16 @@
when: zfs_use_systemd_mount_generator
import_tasks: enable-systemd-mount-generator.yml
+- name: gather zpool facts
+ zpool_facts:
+
+- name: generate list of existing zpools
+ set_fact:
+ zfs_existing_zpools: "{{ ansible_zfs_pools | map(attribute='name') | list }}"
+
- name: create zpools
loop: "{{ zfs_zpools | dict2items }}"
loop_control:
label: "{{ item.key }}"
+ when: item.key not in zfs_existing_zpools
command: "zpool create -m {{ item.value.mountpoint }} {% for prop, value in (item.value.properties | default(zfs_zpool_properties)).items() %}-o {{ prop }}={{ value }} {% endfor %}{{ item.key }} {{ item.value.create_vdevs }}"
- args:
- creates: "{{ item.value.mountpoint }}"