diff --git a/config/ansible/tasks/servers/zfs.yml b/config/ansible/tasks/servers/zfs.yml index a6ab1dd..d32fd72 100644 --- a/config/ansible/tasks/servers/zfs.yml +++ b/config/ansible/tasks/servers/zfs.yml @@ -23,12 +23,20 @@ - zfs-mount - zfs-import.target +- name: Check if datapool exists + ansible.builtin.command: zpool list datapool + register: datapool_check + ignore_errors: true + become: true + changed_when: false + - name: Ensure /mnt directory exists with proper permissions ansible.builtin.file: path: /mnt state: directory mode: "0755" become: true + when: datapool_check.rc == 0 - name: Create mount points ansible.builtin.file: @@ -50,6 +58,7 @@ - /mnt/services - /mnt/stash - /mnt/tvshows + when: datapool_check.rc == 0 - name: Mount ZFS datasets become: true @@ -72,6 +81,7 @@ - { path: /mnt/services, src: datapool/services } - { path: /mnt/stash, src: datapool/stash } - { path: /mnt/tvshows, src: datapool/tv_shows } + when: datapool_check.rc == 0 - name: Set ownership after mounting ansible.builtin.file: @@ -96,3 +106,4 @@ - /mnt/services - /mnt/stash - /mnt/tvshows + when: datapool_check.rc == 0