fix(nut): udevadm trigger before driver start, so first install works #19

Merged
kblack0610 merged 1 commit from fix/nut-udev-trigger into master 2026-06-03 14:39:23 +00:00
Owner

First-time install of NUT on a host where the UPS is already plugged in fails because the package's udev rule (62-nut-usbups.rules) only fires on device-plug events, not on package install. Result: /dev/bus/usb/<bus>/<dev> stays root:root, nut-driver@cyberpower.service exits with libusb1: Could not open any HID devices: insufficient permissions on everything.

Fix: insert a udevadm trigger --action=change --subsystem-match=usb step right before Enable + start nut-driver. Marked changed_when: false since re-triggering is idempotent.

Test plan

  • Reproduced original failure on pi5-master (driver start handler exit code 1)
  • After fix, full apply runs to completion: ok=22, changed=N, failed=0
  • Idempotency: second run is ok=22, changed=0, failed=0
  • upsc cyberpower on pi5-master returns 25+ live metrics (battery 100%, 1525s runtime, CP1500PFCLCDa, serial CXXQX7006052)
First-time install of NUT on a host where the UPS is already plugged in fails because the package's udev rule (`62-nut-usbups.rules`) only fires on device-plug events, not on package install. Result: `/dev/bus/usb/<bus>/<dev>` stays `root:root`, `nut-driver@cyberpower.service` exits with `libusb1: Could not open any HID devices: insufficient permissions on everything`. Fix: insert a `udevadm trigger --action=change --subsystem-match=usb` step right before `Enable + start nut-driver`. Marked `changed_when: false` since re-triggering is idempotent. ## Test plan - [x] Reproduced original failure on pi5-master (driver start handler exit code 1) - [x] After fix, full apply runs to completion: `ok=22, changed=N, failed=0` - [x] Idempotency: second run is `ok=22, changed=0, failed=0` - [x] `upsc cyberpower` on pi5-master returns 25+ live metrics (battery 100%, 1525s runtime, CP1500PFCLCDa, serial CXXQX7006052)
The nut package ships /lib/udev/rules.d/62-nut-usbups.rules which sets
GROUP="nut" on matching USB devices. But udev only evaluates rules on
device events — if the UPS was plugged in BEFORE the package install
(the normal case for first-time deployment), the device node stays
root:root and nut-driver@cyberpower.service fails with:

  libusb1: Could not open any HID devices: insufficient permissions on everything
  No matching HID UPS found

Add a `udevadm trigger --action=change --subsystem-match=usb` step
right before the driver start, so udev re-evaluates against the live
device with the freshly-installed rule in place. Marked
`changed_when: false` because re-triggering is idempotent and shouldn't
register as a state change.

Validated on pi5-master: previous run had failed=1 on the driver-start
handler; after this fix the playbook is failed=0, ok=22, changed=0 on
re-run (idempotency clean).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kblack0610/home-config!19
No description provided.