ntd / ansible-role-nut Goto Github PK
View Code? Open in Web Editor NEWAnsible role to install and configure Nework UPS tools on Debian
License: MIT License
Ansible role to install and configure Nework UPS tools on Debian
License: MIT License
Newest tag is 0.4.0
but the previous one is 1.3.0
, should it actually be 1.4.0
?
The nut role in the upsmon.conf template is always master.
Should not be controlled by nut_role variable?
In modern versions of systemd it is necessary correctly process service names
for example, if Idefine single UPS named "apc"
nut_ups:
- name: apc
...
got error :
RUNNING HANDLER [ntd.nut : restart nut] **********************************************************************************************************************************
failed: (item=nut-driver) => {"ansible_loop_var": "item", "changed": false, "item": "nut-driver", "msg": "Could not find the requested service nut-driver: host"}
because there are no "nut-driver" service in debian 12, but created named "nut-driver@apc" service.
Define additional variable :
nut_services: # Name of the services to enable
- nut-driver@apc
- nut-monitor
- nut-server
This is a really awesome role. Thank you for making it! Looking at the 1.3.0 version of tests/test.yml as examples for setting up a playbook, there are a few things that seem inaccurate/incomplete for the purposes of user documentation and were confusing. I was interested in setting up netclient mode:
# NetClient only mode
- role: ansible-role-nut
nut_mode: netclient
nut_user: monitor
nut_password: Whatever...
nut_ups: []
nut_services:
- nut-monitor
role
seems to have to be ntd.nut
now instead of ansible-role-nut
. The test.yml
says "ansible-role-nut is the uninstalled name of the ntd.nut role", but it's unclear to me what "uninstalled name" means. Maybe this could just use a little verbiage tweak of something like "Use ntd.nut instead of ansible-role-nut if using this in actual playbooks"?nut_ups
is empty, no MONITOR
line will generate in upsmon.conf.nut_role
to "slave" is probably a pretty common need for client devices, right? (I don't have extensive NUT experience.) If so, that would be nice to have in the example.My block ended up looking more like this:
- role: ntd.nut
nut_host: ipaddress
nut_user: monitor
nut_password: monitor
nut_mode: netclient
nut_role: slave
nut_ups:
- name: ups
driver: usbhid
device: na
description: pfsense UPS
nut_services:
- nut-monitor
Given the differences, maybe this complete example is better for the README than the tests file so that the README contains the current "master" example + one client example.
At least with my version of NUT it seems like the "nut_ups_extra" placed after the ups definitions results in failure to load. Here is a simple play:
---
- name: Nut Play
hosts: all
become: yes
tasks:
- name: Nut
include_role:
name: ntd.nut
vars:
nut_ups:
- name: smt1500rm2u
driver: usbhid-ups
device: auto
description: smt1500rm2u
This produces ups.conf:
# Ansible managed
[smt1500rm2u]
driver = usbhid-ups
port = auto
desc = "smt1500rm2u"
maxretry = 3
This will fail to be loaded, however:
> upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Fatal error: 'maxretry' is not a valid variable name for this driver.
Look in the man page or call this driver with -h for a list of
valid variable names and flags.
By simply moving this directive up higher in the file, it is then correct:
# Ansible managed
maxretry = 3
[smt1500rm2u]
driver = usbhid-ups
port = auto
desc = "smt1500rm2u"
So, at least with my version, it appears that global options such as this need to come before any ups sections otherwise it gets confused and thinks they are part of the UPS config.
Looking at the code, it doesn't look like it is possible to use this role in netclient only mode. (Please correct me if I am wrong) My use case is that I have a NAS running NUT as a server and I would like to configure the rest of my machines as clients. Would it be possible to do something like:
if nut_mode == netclient don't configure nut-driver or nut-server
?
Is it intended to install the nut-monitor
GUI package?
I don't think most of the functionality enabled by this role requires the GTK GUI. This package doesn't seem to be available on Debian bullseye, causing the role to fail. Could packages be made configurable or maybe the nut-monitor
package should just be excluded.
The code suggests nut_upsmon_notifycmd can be left out, but when ran without this command, the task crashes:
failed: [<host>] (item=upsmon.conf) => {"ansible_loop_var": "item", "changed": false, "item": "upsmon.conf", "msg": "AnsibleUndefinedVariable: 'nut_upsmon_notifycmd' is undefined"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.