diff --git a/roles/zfs/files/z_resume_scrubs b/roles/zfs/files/z_resume_scrubs new file mode 100644 index 0000000..97f1547 --- /dev/null +++ b/roles/zfs/files/z_resume_scrubs @@ -0,0 +1,9 @@ +#!/bin/bash -e + +# Resume all suspended pool scrubs +for ZPOOL in $(zpool list -H -o name); do + if [ $(zpool status $ZPOOL | grep -c 'scrub paused') -ge 1 ]; then + echo scrub paused for pool $ZPOOL, resuming it + zpool scrub $ZPOOL + fi +done diff --git a/roles/zfs/files/z_suspend_scrubs b/roles/zfs/files/z_suspend_scrubs new file mode 100644 index 0000000..496ffe5 --- /dev/null +++ b/roles/zfs/files/z_suspend_scrubs @@ -0,0 +1,9 @@ +#!/bin/bash -e + +# Suspend any running pool scrubs +for ZPOOL in $(zpool list -H -o name); do + if [ $(zpool status $ZPOOL | grep -c 'scrub in progress') -ge 1 ]; then + echo scrub running for pool $ZPOOL, suspending it + zpool scrub -p $ZPOOL + fi +done diff --git a/roles/zfs/tasks/main.yml b/roles/zfs/tasks/main.yml index 747a146..8004fb7 100644 --- a/roles/zfs/tasks/main.yml +++ b/roles/zfs/tasks/main.yml @@ -30,6 +30,13 @@ template: src=recv-sudo.j2 dest=/etc/sudoers.d/zfs_recv owner=root group=root mode=440 validate='visudo -cf %s' tags: zfs +- name: Deploy pool scrub suspend and resume scripts + copy: src={{ item }} dest=/usr/local/bin/{{ item }} mode=755 + loop: + - z_suspend_scrubs + - z_resume_scrubs + tags: zfs + - name: Deploy ssh keys for zfs-recv authorized_key: user: zfs-recv