nut: Infer role from server name, set commands

Since the "primary" `upsmon` is always (for our purposes) running on the
same host as `upsd`, there's no reason to specify both values.

All systems need a shutdown command; one is not set by default.

The primary system is the only one that should send notifications.
master
Dustin 2024-01-19 17:57:20 -06:00
parent caccffcb65
commit 36fd137897
2 changed files with 10 additions and 3 deletions

12
env/prod/nut.cue vendored
View File

@ -73,7 +73,6 @@ nut: schema.#Nut & {
#nut_monitor: {
#server: string | *ups_server
#username: string
#role: "primary" | *"secondary"
monitor: [
for k, v in nut.ups {
@ -82,10 +81,19 @@ nut: schema.#Nut & {
powervalue: 1
username: #username
password: nut.users[#username].password
role: #role
if #server == "localhost" {
role: "primary"
}
if #server != "localhost" {
role: "secondary"
}
}
},
]
shutdowncmd: "systemctl poweroff"
if #server == "localhost" {
notifycmd: "/usr/local/libexec/nut-notify"
}
minsupplies: 1
}

View File

@ -9,7 +9,6 @@ nut: prod.nut
nut: monitor: prod.#nut_monitor & {
#server: "localhost"
#username: "upsmon"
#role: "primary"
}
collectd: prod.collectd