Installs and configures NUT (Nework UPS tools) on Debian, ArchLinux and RedHat based systems.
Available variables are listed below, along with default values (see
defaults/main.yml):
| Variable | Default Value | Description |
|---|---|---|
nut_managed_config |
true |
If this is set to false, none of the following options will have any effect, that is any and all changes under /etc/nut/ will be your responsibility. This can be desirable if you have complex configurations. |
nut_enable_service |
true |
Whether to start the NUT service after configuration |
nut_mode |
standalone |
NUT mode setting (see man 5 nut.conf MODE directive) |
nut_extra |
empty | Additional configuration options directly placed in nut.conf. This code is intended to be sourced by shell scripts: you MUST NOT use spaces around the equal sign! |
nut_services |
[nut-server.service, nut-monitor.service, nut.target] |
List of NUT services, excluding driver-related ones, to enable |
nut_users |
See example below | List of users for NUT configuration (replaces legacy user variables). See below for detailed schema. |
nut_ups |
See example below | List of UPS configurations with name, driver, device, description |
nut_ups_extra |
maxretry = 3 |
Additional configuration options directly placed in ups.conf |
nut_upsd_extra |
Multi-line config | Additional upsd daemon configuration directly placed in upsd.conf |
nut_maxretry |
3 |
DEPRECATED - Use nut_ups_extra instead |
This settings are primarily used for the local upsmon.conf configuration.
| Variable | Default Value | Description |
|---|---|---|
nut_host |
localhost |
Hostname of the NUT server to monitor |
nut_powervalue |
1 |
Power value for MONITOR directive (see man 5 upsmon.conf) |
nut_user |
empty | DEPRECATED - Legacy user configuration, migrate to nut_users |
nut_password |
empty | DEPRECATED - Legacy password configuration, migrate to nut_users |
nut_role |
empty | DEPRECATED - Legacy role configuration, migrate to nut_users |
nut_upsmon_user |
Auto-derived | Use this variable to override how the upsmon username is derived. If you override, make sure to create the required user yourself. |
nut_upsmon_password |
Auto-derived | Use this variable to override how the upsmon users password is derived. If you override, make sure to create the required user yourself. |
nut_upsmon_role |
Auto-derived | Use this variable to override how the upsmon users role is derived. If you override, make sure to create the required user yourself. |
nut_upsmon_extra |
Multi-line config | Additional upsmon configuratio directly placed in upsmon.conf |
nut_upsmon_notifycmd |
undefined | Path for NOTIFYCMD configuration |
nut_upsmon_notifycmd_content |
undefined | Content to copy to the notifycmd path |
Refer to the Users Definition section below for details on how to configure users.
nut_ups:
- name: UPS
driver: riello_ups
device: /dev/ttyUSB0
description: Some descriptive information
extra: |
maxretry = 10
retrydelay = 1name is an arbitrary string that must identify univocally the UPS.
driver depends on your hardware and must be one of the available NUT
driver. Be sure the NUT
version installed on your server has that specific driver available.
device is device where the UPS is listening (typically an USB port or
a serial device).
description is optional and is an arbitrary string used for debugging
and reporting purposes.
extra is an optional multiline text to be inserted verbatim in the
relevant UPS section.
Other less used variables, all of them optionals:
nut_mode: standalone # `man 5 nut.conf` MODE directive
nut_powervalue: 1 # `man 5 upsmon.conf` MONITOR directive, powervalue field
nut_role: master # `man 5 upsmon.conf` MONITOR directive, type field
nut_services: # Name of non-driver services to enable
- nut-server.service
- nut-monitor.service
- nut.target
The NUT users are configured using the nut_users variable, see
nested scheme below. You can optionally specify extra configuration
snippets that are added to each user.
The legacy variables nut_user, nut_password and nut_role are now
deprecated. For now, the behaviour is as follows:
- If
nut_useris defined, the legacy variables will be added toupsd.usersand will be used inupsmon.conf - If
nut_useris not defined, the first entry ofnut_userswill be used inupsmon.conf
This default behaviour can be overriden by explicitely setting
the nut_upsmon_* variables. Note that in this case you are still
responsible to create the same user in upsd.users (for example by
adding it to nut_users): the role does not do that automatically.
nut_users:
- name: nutuser1
password: password1
role: primary # DEPRECATED: use extra instead
- name: nutuser2
password: password2
extra: |
role = admin
actions = set
actions = fsdThe role of the first user will be used as type field in the
MONITOR directive of upsmon.conf. This is deprecated: it is better
to explicitely specify it in nut_upsmon_role or let the default value
(master, now mapping to primary).
nut_users:
- name: masteruser
password: masterpassword
- name: slaveuser
password: slavepassword
extra: |
upsmon slaveFor a detailed description on user attributes that can be set,
please refer to the upsd.users documentation.
- hosts: all
roles:
- role: ntd.nut
nut_ups:
- name: riello
driver: riello_usb
device: /dev/ups
description: iPlug 800For many more examples, please see tests/test.yml.
MIT
This role was created in 2016 by Nicola Fontana ([email protected]).