setup NUT
This commit is contained in:
parent
e8fcdc3855
commit
7548a5fd80
|
@ -277,4 +277,18 @@ hydroqc2mqtt:
|
|||
66363939656339373365303532313365333964326139643261653832653132636237
|
||||
|
||||
homeassistant:
|
||||
version: 2024.1.3
|
||||
version: 2024.1.3
|
||||
|
||||
nut_server:
|
||||
ansible_host: usbip
|
||||
ups:
|
||||
liebert-ps1:
|
||||
driver: usbhid-ups
|
||||
vendorid: "10af"
|
||||
productid: "0001"
|
||||
|
||||
nut_client:
|
||||
ups: liebert-ps1
|
||||
sched:
|
||||
# How many seconds we are allowed to run on battery
|
||||
on_bat: 300
|
10
hosts
10
hosts
|
@ -18,6 +18,11 @@ all:
|
|||
hosts:
|
||||
router-0:
|
||||
ansible_host: 192.168.10.10
|
||||
nut_client:
|
||||
ups: liebert-ps1
|
||||
sched:
|
||||
# We want to shutdown this server last
|
||||
on_bat: 3600
|
||||
server-0:
|
||||
ansible_host: 192.168.10.11
|
||||
vfio_pci_ids:
|
||||
|
@ -28,6 +33,11 @@ all:
|
|||
# - '1002:731f' # Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]
|
||||
- '10de:13c2' # NVIDIA Corporation GM204 [GeForce GTX 970]
|
||||
- '10de:13f1' # VGA compatible controller [0300]: NVIDIA Corporation GM204GL [Quadro M4000]
|
||||
nut_client:
|
||||
ups: liebert-ps1
|
||||
sched:
|
||||
# We want to shutdown this server quick
|
||||
on_bat: 10
|
||||
bastion:
|
||||
hosts:
|
||||
bastion:
|
||||
|
|
15
playbook.yml
15
playbook.yml
|
@ -1,13 +1,22 @@
|
|||
|
||||
- hosts: usbip
|
||||
roles:
|
||||
- usbip
|
||||
- nut-server
|
||||
|
||||
- hosts: proxmox
|
||||
roles:
|
||||
- proxmox
|
||||
- nut-client
|
||||
|
||||
- hosts: k3s-server
|
||||
roles:
|
||||
- k3s-server
|
||||
- nut-client
|
||||
- hosts: k3s-agent
|
||||
roles:
|
||||
- k3s-agent
|
||||
- nut-client
|
||||
|
||||
- hosts: generic-linux
|
||||
roles:
|
||||
|
@ -52,8 +61,4 @@
|
|||
|
||||
- hosts: cups
|
||||
roles:
|
||||
- cups
|
||||
|
||||
- hosts: usbip
|
||||
roles:
|
||||
- usbip
|
||||
- cups
|
|
@ -6,7 +6,7 @@ After=network-online.target
|
|||
Type=notify
|
||||
ExecStartPre=-/sbin/modprobe br_netfilter
|
||||
ExecStartPre=-/sbin/modprobe overlay
|
||||
ExecStart=/usr/local/bin/k3s agent --server https://{{ hostvars[groups['k3s-server'][0]]['ansible_facts']['default_ipv4']['address'] }}:6443 --token {{ hostvars[groups['k3s-server'][0]]['token'] }} {{ k3s.extra_agent_args | default("") }} {{ k3s_extra_args }}
|
||||
ExecStart=/usr/local/bin/k3s agent --server https://{{ hostvars[groups['k3s-server'][0]]['ansible_default_ipv4']['address'] }}:6443 --token {{ hostvars[groups['k3s-server'][0]]['token'] }} {{ k3s.extra_agent_args | default("") }} {{ k3s_extra_args }}
|
||||
KillMode=process
|
||||
Delegate=yes
|
||||
# Having non-zero Limit*s causes performance problems due to accounting overhead
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
MODE=netclient
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
case $1 in
|
||||
shutdown)
|
||||
logger -t upssched-cmd "UPS on battery too long, shutdown"
|
||||
/usr/bin/sudo /usr/sbin/shutdown -h +0
|
||||
;;
|
||||
shutdown-critical)
|
||||
logger -t upssched-cmd "UPS on battery critical, forced shutdown"
|
||||
/usr/sbin/upsmon -c fsd
|
||||
;;
|
||||
*)
|
||||
logger -t upssched-cmd "Unrecognized command: $1"
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,5 @@
|
|||
- name: Restart nut-client
|
||||
service:
|
||||
name: nut-client
|
||||
enabled: true
|
||||
state: restarted
|
|
@ -0,0 +1,41 @@
|
|||
- name: Install NUT
|
||||
apt:
|
||||
update_cache: true
|
||||
name:
|
||||
- nut-client
|
||||
|
||||
- name: Configure upsmon.conf
|
||||
template:
|
||||
src: upsmon.conf
|
||||
dest: /etc/nut/upsmon.conf
|
||||
notify:
|
||||
- Restart nut-client
|
||||
|
||||
- name: Configure nut.conf
|
||||
copy:
|
||||
src: nut.conf
|
||||
dest: /etc/nut/nut.conf
|
||||
notify:
|
||||
- Restart nut-client
|
||||
|
||||
- name: Configure upssched.conf
|
||||
template:
|
||||
src: upssched.conf
|
||||
dest: /etc/nut/upssched.conf
|
||||
notify:
|
||||
- Restart nut-client
|
||||
|
||||
- name: Configure upssched-cmd
|
||||
copy:
|
||||
src: upssched-cmd
|
||||
dest: /etc/nut/upssched-cmd
|
||||
mode: '0755'
|
||||
notify:
|
||||
- Restart nut-client
|
||||
|
||||
- name: Allow nut user to invoke shutdown with sudo
|
||||
lineinfile:
|
||||
path: /etc/sudoers
|
||||
line: 'nut ALL=NOPASSWD: /usr/sbin/shutdown'
|
||||
regexp: '^nut\s+'
|
||||
validate: '/usr/sbin/visudo -cf %s'
|
|
@ -0,0 +1,21 @@
|
|||
# TODO: setup credentials
|
||||
MONITOR {{ nut_client.ups }}@{{ hostvars[nut_server.ansible_host]['ansible_default_ipv4']['address'] }} 1 monuser admin secondary
|
||||
|
||||
|
||||
MINSUPPLIES 1
|
||||
SHUTDOWNCMD "/sbin/shutdown -h +0"
|
||||
NOTIFYCMD /usr/sbin/upssched
|
||||
POLLFREQ 5
|
||||
POLLFREQALERT 5
|
||||
HOSTSYNC 15
|
||||
DEADTIME 15
|
||||
POWERDOWNFLAG /run/killpower
|
||||
|
||||
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
|
||||
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
|
||||
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
|
||||
|
||||
RBWARNTIME 43200
|
||||
NOCOMMWARNTIME 300
|
||||
|
||||
FINALDELAY 5
|
|
@ -0,0 +1,11 @@
|
|||
CMDSCRIPT /etc/nut/upssched-cmd
|
||||
PIPEFN /run/nut/upssched.pipe
|
||||
LOCKFN /run/nut/upssched.lock
|
||||
|
||||
AT ONBATT * START-TIMER shutdown {{ nut_client.sched.on_bat }}
|
||||
AT ONLINE * CANCEL-TIMER shutdown
|
||||
AT LOWBATT * EXECUTE shutdown-critical
|
||||
#AT COMMBAD * START-TIMER commbad {#{ nut_client.sched.comm_bad}#}
|
||||
#AT COMMOK * CANCEL-TIMER commbad commok
|
||||
#AT NOCOMM * EXECUTE commbad
|
||||
#AT SHUTDOWN * EXECUTE powerdown
|
|
@ -0,0 +1 @@
|
|||
MODE=netserver
|
|
@ -0,0 +1 @@
|
|||
LISTEN 0.0.0.0 3493
|
|
@ -0,0 +1,4 @@
|
|||
# TODO: setup credentials
|
||||
[monuser]
|
||||
password = admin
|
||||
upsmon secondary
|
|
@ -0,0 +1,17 @@
|
|||
- name: Restart nut-server
|
||||
service:
|
||||
name: nut-server
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart nut-client
|
||||
service:
|
||||
name: nut-server
|
||||
enabled: true
|
||||
state: restarted
|
||||
|
||||
- name: Restart nut-monitor
|
||||
service:
|
||||
name: nut-monitor
|
||||
enabled: true
|
||||
state: restarted
|
|
@ -0,0 +1,52 @@
|
|||
- name: Install NUT
|
||||
apt:
|
||||
update_cache: true
|
||||
name:
|
||||
- nut
|
||||
- nut-client
|
||||
- nut-server
|
||||
|
||||
- name: Configure ups.conf
|
||||
template:
|
||||
src: ups.conf
|
||||
dest: /etc/nut/ups.conf
|
||||
notify:
|
||||
- Restart nut-server
|
||||
- Restart nut-client
|
||||
- Restart nut-monitor
|
||||
|
||||
- name: Configure upsmon.conf
|
||||
template:
|
||||
src: upsmon.conf
|
||||
dest: /etc/nut/upsmon.conf
|
||||
notify:
|
||||
- Restart nut-server
|
||||
- Restart nut-client
|
||||
- Restart nut-monitor
|
||||
|
||||
- name: Configure upsd.conf
|
||||
copy:
|
||||
src: upsd.conf
|
||||
dest: /etc/nut/upsd.conf
|
||||
notify:
|
||||
- Restart nut-server
|
||||
- Restart nut-client
|
||||
- Restart nut-monitor
|
||||
|
||||
- name: Configure nut.conf
|
||||
copy:
|
||||
src: nut.conf
|
||||
dest: /etc/nut/nut.conf
|
||||
notify:
|
||||
- Restart nut-server
|
||||
- Restart nut-client
|
||||
- Restart nut-monitor
|
||||
|
||||
- name: Configure upsd.users
|
||||
copy:
|
||||
src: upsd.users
|
||||
dest: /etc/nut/upsd.users
|
||||
notify:
|
||||
- Restart nut-server
|
||||
- Restart nut-client
|
||||
- Restart nut-monitor
|
|
@ -0,0 +1,9 @@
|
|||
maxretry = 3
|
||||
|
||||
{% for name, config in nut_server.ups.items() %}
|
||||
[{{ name }}]
|
||||
driver = {{ config.driver }}
|
||||
port = auto
|
||||
vendorid = {{ config.vendorid }}
|
||||
productid = {{ config.productid }}
|
||||
{% endfor %}
|
|
@ -0,0 +1,4 @@
|
|||
# TODO: setup credentials
|
||||
{% for name in nut_server.ups.keys() %}
|
||||
MONITOR {{ name }}@localhost 1 monuser admin primary
|
||||
{% endfor %}
|
Loading…
Reference in New Issue