aboutsummaryrefslogtreecommitdiff
path: root/roles/monitoring/tasks/zfs.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/monitoring/tasks/zfs.yaml')
-rw-r--r--roles/monitoring/tasks/zfs.yaml49
1 files changed, 49 insertions, 0 deletions
diff --git a/roles/monitoring/tasks/zfs.yaml b/roles/monitoring/tasks/zfs.yaml
new file mode 100644
index 0000000..2f18e32
--- /dev/null
+++ b/roles/monitoring/tasks/zfs.yaml
@@ -0,0 +1,49 @@
+# https://github.com/pdf/zfs_exporter
+
+---
+
+# ZFS Exporter for ZFS monitoring
+
+- name: 'Download zfs exporter tarball'
+ get_url:
+ url: 'https://github.com/pdf/zfs_exporter/releases/download/v2.2.5/zfs_exporter-2.2.5.linux-arm64.tar.gz'
+ dest: '{{ monitoring_root_dir }}/zfs_exporter.tar.gz'
+ mode: '644'
+
+- name: 'Ensure the zfs exporter dir exists'
+ file:
+ path: '{{ monitoring_root_dir }}/zfs_exporter-2.2.5.linux-arm64'
+ state: 'directory'
+ mode: '755'
+
+- name: 'Extract ZFS exporter to dir'
+ command: 'tar -xf zfs_exporter-2.2.5.linux-arm64.tar.gz'
+ args:
+ chdir: '{{ monitoring_root_dir }}'
+
+- name: 'Copy the executable to /usr/bin'
+ become: true
+ become_method: 'doas'
+ copy:
+ src: '{{ monitoring_root_dir }}/zfs_exporter-2.2.5.linux-arm64/zfs_exporter'
+ dest: '/usr/bin/zfs_exporter'
+ mode: '0755'
+ owner: 'root'
+ remote_src: true
+
+- name: 'Create service file to start zfs_exporter on boot'
+ become: true
+ become_method: 'doas'
+ copy:
+ src: 'zfs-exporter'
+ dest: '/etc/init.d/zfs-exporter'
+ mode: '0755'
+ owner: 'root'
+
+- name: 'Start and enable the zfs-exporter service'
+ become: true
+ become_method: 'doas'
+ service:
+ name: 'zfs-exporter'
+ state: 'started'
+ enabled: true