diff --git a/inventory.yml b/inventory.yml index c0b45b8..71e637b 100644 --- a/inventory.yml +++ b/inventory.yml @@ -18,10 +18,6 @@ nameservers: monitoring: hosts: - hypervisor-d.home.finn.io: - ansible_host: 10.5.1.123 - home_network: true - http.home.finn.io: ansible_host: 10.5.1.245 home_network: true @@ -115,3 +111,9 @@ signal_bots: hosts: signald-2: home_network: true + +hypervisors: + hosts: + hypervisor-d.home.finn.io: + ansible_host: 10.5.1.123 + home_network: true diff --git a/playbook-hypervisor.yaml b/playbook-hypervisor.yaml new file mode 100644 index 0000000..192d2ac --- /dev/null +++ b/playbook-hypervisor.yaml @@ -0,0 +1,7 @@ +- hosts: hypervisors + vars: + ansible_user: root + roles: + - base + - monitoring + - hypervisor diff --git a/roles/hypervisor/handlers/main.yaml b/roles/hypervisor/handlers/main.yaml new file mode 100644 index 0000000..5ed7f04 --- /dev/null +++ b/roles/hypervisor/handlers/main.yaml @@ -0,0 +1,7 @@ +- name: systemctl daemon-reload + command: systemctl daemon-reload + +- name: restart apcupsd_exporter + service: + name: apcupsd_exporter + state: restarted diff --git a/roles/hypervisor/tasks/main.yml b/roles/hypervisor/tasks/main.yml new file mode 100644 index 0000000..173d7f7 --- /dev/null +++ b/roles/hypervisor/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: ups.yaml diff --git a/roles/hypervisor/tasks/ups.yaml b/roles/hypervisor/tasks/ups.yaml new file mode 100644 index 0000000..7dd6a92 --- /dev/null +++ b/roles/hypervisor/tasks/ups.yaml @@ -0,0 +1,27 @@ +- name: Install apcupsd + apt: + name: apcupsd + +- name: download apcupsd_exporter + get_url: + url: https://git.janky.solutions/api/packages/JankySolutions/generic/infra-apcupsd_exporter/4c09b127c353cd57e6bc369f510fe516a0f65c0d/apcupsd_exporter + checksum: sha256:b17cc67d8ea9c6f1494b581a57a2315e33abf6dfb8edf2e1c14a50a0fb85e768 + dest: /usr/local/bin/apcupsd_exporter + mode: "0755" + notify: + - restart apcupsd_exporter + +- name: install apcupsd_exporter service + template: + src: apcupsd_exporter.service + dest: /etc/systemd/system/apcupsd_exporter.service + notify: + - systemctl daemon-reload + - restart apcupsd_exporter + +- meta: flush_handlers + +- name: enable apcupsd_exporter + service: + name: apcupsd_exporter + enabled: true diff --git a/roles/hypervisor/templates/apcupsd_exporter.service b/roles/hypervisor/templates/apcupsd_exporter.service new file mode 100644 index 0000000..1283ea2 --- /dev/null +++ b/roles/hypervisor/templates/apcupsd_exporter.service @@ -0,0 +1,14 @@ +[Unit] +Description=apcupsd prometheus exporter +After=network.target + +[Service] +Type=simple +User=nobody +Group=nogroup +ExecStart=/usr/local/bin/apcupsd_exporter +Restart=always +RestartSec=30 + +[Install] +WantedBy=multi-user.target