From 92749ddfe457474878dd85b0fbf188b98b2c137e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 26 Jan 2021 17:00:07 +0100 Subject: [PATCH] Update to 2021-01-26 17:00 --- roles/zfs/files/z_resume_scrubs | 9 +++++++++ roles/zfs/files/z_suspend_scrubs | 9 +++++++++ roles/zfs/tasks/main.yml | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 roles/zfs/files/z_resume_scrubs create mode 100644 roles/zfs/files/z_suspend_scrubs 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