From c0a8ceefc6132f403f8a91a034bca65aae1a5f66 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 5 Aug 2024 00:19:14 -0700 Subject: [PATCH] add smartctl_exporter to hypervisors --- roles/hypervisor/handlers/main.yaml | 5 ++++ roles/hypervisor/tasks/main.yml | 1 + roles/hypervisor/tasks/smartmontools.yaml | 27 +++++++++++++++++++ .../templates/smartctl_exporter.service | 12 +++++++++ 4 files changed, 45 insertions(+) create mode 100644 roles/hypervisor/tasks/smartmontools.yaml create mode 100644 roles/hypervisor/templates/smartctl_exporter.service diff --git a/roles/hypervisor/handlers/main.yaml b/roles/hypervisor/handlers/main.yaml index 5ed7f04..46f4d65 100644 --- a/roles/hypervisor/handlers/main.yaml +++ b/roles/hypervisor/handlers/main.yaml @@ -5,3 +5,8 @@ service: name: apcupsd_exporter state: restarted + +- name: restart smartctl_exporter + service: + name: smartctl_exporter + state: restarted diff --git a/roles/hypervisor/tasks/main.yml b/roles/hypervisor/tasks/main.yml index 173d7f7..4dab298 100644 --- a/roles/hypervisor/tasks/main.yml +++ b/roles/hypervisor/tasks/main.yml @@ -1 +1,2 @@ - include_tasks: ups.yaml +- include_tasks: smartmontools.yaml diff --git a/roles/hypervisor/tasks/smartmontools.yaml b/roles/hypervisor/tasks/smartmontools.yaml new file mode 100644 index 0000000..8272396 --- /dev/null +++ b/roles/hypervisor/tasks/smartmontools.yaml @@ -0,0 +1,27 @@ +- name: Install smartmontools + apt: + name: smartmontools + +- name: download smartctl_exporter + get_url: + url: https://git.janky.solutions/api/packages/JankySolutions/generic/infra-smartctl-exporter/0daa62681994c374e0915dbff2125f1bd8693e00/smartctl_exporter + checksum: sha256:01af30f3f46db761b8721dff3dd7517cb5c6d82ae4cd919fbfac0c43d8a78e90 + dest: /usr/local/bin/smartctl_exporter + mode: "0755" + notify: + - restart smartctl_exporter + +- name: install smartctl_exporter service + template: + src: smartctl_exporter.service + dest: /etc/systemd/system/smartctl_exporter.service + notify: + - systemctl daemon-reload + - restart smartctl_exporter + +- meta: flush_handlers + +- name: enable smartctl_exporter + service: + name: smartctl_exporter + enabled: true diff --git a/roles/hypervisor/templates/smartctl_exporter.service b/roles/hypervisor/templates/smartctl_exporter.service new file mode 100644 index 0000000..dd6d7a2 --- /dev/null +++ b/roles/hypervisor/templates/smartctl_exporter.service @@ -0,0 +1,12 @@ +[Unit] +Description=smartctl prometheus exporter +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/smartctl_exporter +Restart=always +RestartSec=30 + +[Install] +WantedBy=multi-user.target