nut for pikvm
parent
103834c6f3
commit
d4eee168fa
|
@ -166,8 +166,9 @@
|
||||||
|
|
||||||
- name: set up NUT
|
- name: set up NUT
|
||||||
hosts:
|
hosts:
|
||||||
- suricata
|
|
||||||
- narwhal
|
- narwhal
|
||||||
|
- pikvm
|
||||||
|
- suricata
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- nut
|
- nut
|
||||||
|
|
17
hosts.yml
17
hosts.yml
|
@ -11,6 +11,23 @@ all:
|
||||||
dags:
|
dags:
|
||||||
- acme_rsync
|
- 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:
|
snitch:
|
||||||
ansible_host: snitch
|
ansible_host: snitch
|
||||||
ansible_user: ansible
|
ansible_user: ansible
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
name: nut
|
name: nut
|
||||||
when: ansible_distribution == "Alpine"
|
when: ansible_distribution == "Alpine"
|
||||||
|
|
||||||
- name: keep nut-server uninstalled from Debian/Ubuntu in client mode
|
- name: install NUT for Arch
|
||||||
apt:
|
pacman:
|
||||||
name: nut-server
|
name: nut
|
||||||
state: absent
|
when: ansible_distribution == "Archlinux"
|
||||||
when: ansible_distribution in ["Debian", "Ubuntu"] and nut_mode == "netclient"
|
|
||||||
|
|
||||||
- name: set NUT mode
|
- name: set NUT mode
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -17,6 +16,10 @@
|
||||||
regexp: '^MODE='
|
regexp: '^MODE='
|
||||||
line: "MODE={{ nut_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
|
- name: set up upsd
|
||||||
include_tasks: upsd.yml
|
include_tasks: upsd.yml
|
||||||
when: nut_mode in ["standalone", "netserver"]
|
when: nut_mode in ["standalone", "netserver"]
|
||||||
|
|
|
@ -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"
|
|
@ -34,3 +34,17 @@
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
when: ansible_distribution == "Alpine"
|
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"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
block: |
|
block: |
|
||||||
MONITOR {{ nut_device.name }}@{{ nut_host }} 1 upsmon {{ nut_upsmon_password }} {{ nut_types[nut_mode] }}
|
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:
|
service:
|
||||||
name: nut-upsmon
|
name: nut-upsmon
|
||||||
runlevel: default
|
runlevel: default
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
enabled: true
|
enabled: true
|
||||||
when: ansible_distribution == "Alpine"
|
when: ansible_distribution == "Alpine"
|
||||||
|
|
||||||
- name: start and enable nut-monitor
|
- name: start and enable nut-monitor with systemd
|
||||||
systemd:
|
systemd:
|
||||||
name: nut-monitor
|
name: nut-monitor
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
when: ansible_distribution in ["Debian", "Ubuntu"]
|
when: ansible_distribution in ["Debian", "Ubuntu", "Archlinux"]
|
||||||
|
|
Loading…
Reference in New Issue