nut for pikvm

main
Ricard Illa 2023-01-25 17:01:36 +01:00
parent 103834c6f3
commit d4eee168fa
6 changed files with 58 additions and 9 deletions

View File

@ -166,8 +166,9 @@
- name: set up NUT
hosts:
- suricata
- narwhal
- pikvm
- suricata
become: true
roles:
- nut

View File

@ -11,6 +11,23 @@ all:
dags:
- acme_rsync
nut_mode: netclient
nut_upsmon_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
313636333565356536333862386361393439666563353938343934623532366
433363738623862623035663138643532346330346339376437353563633365
320a33356464656230316565376339333331373832643631366562666331333
137386235666437663766313833616135303339643539353931313966623638
3962360a3131383461393435633363366437663535306430343631313935343
465343465343038383961306132653066643933646237313234326435663834
3865663534
nut_device:
name: "cps-homelab"
nut_host: "nut.monotremata.xyz"
snitch:
ansible_host: snitch
ansible_user: ansible

View File

@ -5,11 +5,10 @@
name: nut
when: ansible_distribution == "Alpine"
- name: keep nut-server uninstalled from Debian/Ubuntu in client mode
apt:
name: nut-server
state: absent
when: ansible_distribution in ["Debian", "Ubuntu"] and nut_mode == "netclient"
- name: install NUT for Arch
pacman:
name: nut
when: ansible_distribution == "Archlinux"
- name: set NUT mode
lineinfile:
@ -17,6 +16,10 @@
regexp: '^MODE='
line: "MODE={{ nut_mode }}"
- name: prevent nut-server when using netclient mode
include_tasks: netclient.yml
when: nut_mode == "netclient"
- name: set up upsd
include_tasks: upsd.yml
when: nut_mode in ["standalone", "netserver"]

View File

@ -0,0 +1,14 @@
---
- name: keep nut-server uninstalled from Debian/Ubuntu in client mode
apt:
name: nut-server
state: absent
when: ansible_distribution in ["Debian", "Ubuntu"]
- name: mask nut-server when using client-only with Arch
systemd:
name: nut-server
state: stopped
masked: true
when: ansible_distribution == "Archlinux"

View File

@ -34,3 +34,17 @@
state: started
enabled: true
when: ansible_distribution == "Alpine"
- name: start and enable nut-server
systemd:
name: nut-server
state: started
enabled: true
when: ansible_distribution in ["Debian", "Ubuntu"]
- name: start and enable nut-driver-enumerator
systemd:
name: nut-driver-enumerator
state: started
enabled: true
when: ansible_distribution == "Archlinux"

View File

@ -11,7 +11,7 @@
block: |
MONITOR {{ nut_device.name }}@{{ nut_host }} 1 upsmon {{ nut_upsmon_password }} {{ nut_types[nut_mode] }}
- name: start and enable nut-upsmon
- name: start and enable nut-upsmon with openrc
service:
name: nut-upsmon
runlevel: default
@ -19,9 +19,9 @@
enabled: true
when: ansible_distribution == "Alpine"
- name: start and enable nut-monitor
- name: start and enable nut-monitor with systemd
systemd:
name: nut-monitor
state: started
enabled: true
when: ansible_distribution in ["Debian", "Ubuntu"]
when: ansible_distribution in ["Debian", "Ubuntu", "Archlinux"]